-
Notifications
You must be signed in to change notification settings - Fork 847
230 lines (183 loc) · 7.22 KB
/
vvv-provisioning.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: VVV Provisioning
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the develop branch
on:
push:
branches:
- develop
pull_request:
branches:
- develop
- stable
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
on-docker:
name: Ubuntu 20 Docker Provisioner
# The type of runner that the job will run on
runs-on: ubuntu-20.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Make Symlinks
- name: Create Vagrant Like Environment
run: |
# uninstall pre installed packages (to test if extensions work)
sudo apt-get -q --autoremove --purge remove php*
sudo apt-get -q autoclean
# remove pre-installed composer
if [ -f /usr/bin/composer ]; then
sudo rm -f /usr/bin/composer
fi
# create vagrant user
sudo groupadd -g 2000 vagrant
sudo useradd -u 2000 -g vagrant -m vagrant
# vvv_symlink function to sumulate synced folders
function vvv_symlink() {
if [ ! -d "${1}" ]; then
sudo mkdir -p "${1}"
fi
sudo chown -R vagrant:vagrant "${1}"
sudo ln -sf "${1}" "${2}"
}
# create srv folder
sudo -u "vagrant" mkdir -p "/srv"
# copy files provided by vagrant
sudo cp -f "$GITHUB_WORKSPACE/config/default-config.yml" "$GITHUB_WORKSPACE/config/config.yml"
sudo cp -f "$GITHUB_WORKSPACE/version" "/home/vagrant/version"
# make folders available
vvv_symlink "$GITHUB_WORKSPACE/database/sql" "/srv/database"
vvv_symlink "$GITHUB_WORKSPACE/config" "/srv/config"
vvv_symlink "$GITHUB_WORKSPACE/provision" "/srv/provision"
vvv_symlink "$GITHUB_WORKSPACE/certificates" "/srv/certificates"
vvv_symlink "$GITHUB_WORKSPACE/www" "/srv/www"
vvv_symlink "$GITHUB_WORKSPACE/log/memcached" "/var/log/memcached"
vvv_symlink "$GITHUB_WORKSPACE/log/nginx" "/var/log/nginx"
vvv_symlink "$GITHUB_WORKSPACE/log/php" "/var/log/php"
vvv_symlink "$GITHUB_WORKSPACE/log/provisioners" "/var/log/provisioners"
# Runs the provisioners in the expected order
- name: Run provison-pre.sh
run: sudo bash -c '. "/srv/provision/tests/provisioners.sh" && pre_hook'
- name: Run provision.sh
run: sudo bash -c '. "/srv/provision/tests/provisioners.sh" && provision_main'
- name: Run provision-tools.sh
run: sudo bash -c '. "/srv/provision/tests/provisioners.sh" && provision_tools'
- name: Run provison-dashboard.sh
run: sudo bash -c '. "/srv/provision/tests/provisioners.sh" && provision_dashboard'
- name: Run provision-extension-source.sh
run: sudo bash -c '. "/srv/provision/tests/provisioners.sh" && provision_extension_sources'
- name: Run provision-extension.sh
run: sudo bash -c '. "/srv/provision/tests/provisioners.sh" && provision_extensions'
- name: Run provision-site.sh
run: sudo bash -c '. "/srv/provision/tests/provisioners.sh" && provision_sites'
- name: Run provision-post.sh
run: sudo bash -c '. "/srv/provision/tests/provisioners.sh" && post_hook'
# At this point, we would run some extra tests
# TODO: Ideas
# - Add screenshots of provisioned sites
# - CURL mailhog API to see if it's working or not
# - Check VM hostfile
- name: Prepare Output
if: ${{ always() }}
run: |
MYUID=$(id -u -n)
MYGID=$(id -g -n)
sudo chown -R $MYUID:$MYGID "$GITHUB_WORKSPACE/log"
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: logs-on-docker
path: "${{ github.workspace }}/log"
# This workflow contains a single job called "build"
on-stable:
name: MacOS 10.15 Stable Reprovision
# The type of runner that the job will run on
runs-on: macos-10.15
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
ref: stable
- name: Cache Vagrant boxes
uses: actions/cache@v2
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-
- name: install goodhosts
run: vagrant plugin install --local
- name: vagrant up (stable)
run: vagrant up
- uses: actions/checkout@v2
with:
clean: false
- name: vagrant up (current branch)
run: vagrant up --provision
- name: tests
run: provision/tests/macos-tests.sh
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: logs-on-stable
path: "${{ github.workspace }}/log"
on-develop:
name: MacOS 10.15 Develop Reprovision
# The type of runner that the job will run on
runs-on: macos-10.15
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
ref: develop
- name: Cache Vagrant boxes
uses: actions/cache@v2
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-
- name: install goodhosts
run: vagrant plugin install --local
- name: vagrant up (develop)
run: vagrant up
- uses: actions/checkout@v2
with:
clean: false
- name: vagrant up (current branch)
run: vagrant up --provision
- name: tests
run: provision/tests/macos-tests.sh
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: logs-on-develop
path: "${{ github.workspace }}/log"
on-clean:
name: MacOS 10.15 Clean Provision
# The type of runner that the job will run on
runs-on: macos-10.15
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Cache Vagrant boxes
uses: actions/cache@v2
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-
- name: install goodhosts
run: vagrant plugin install --local
- name: vagrant up (current branch)
run: vagrant up
- name: tests
run: provision/tests/macos-tests.sh
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: logs-on-clean
path: "${{ github.workspace }}/log"