-
Notifications
You must be signed in to change notification settings - Fork 847
111 lines (90 loc) · 4 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
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@v4
# 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* mysql*
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@v4
if: ${{ always() }}
with:
name: logs-on-docker
path: "${{ github.workspace }}/log"