-
Notifications
You must be signed in to change notification settings - Fork 3
101 lines (85 loc) · 2.69 KB
/
main.yaml
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
name: MVM Unit Tests & Tagged Deploy
on:
push:
branches:
- '*'
tags:
- '*'
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Make .env.test.local
run: |
touch .env.test.local
echo DATABASE_URL="mysql://mvm:[email protected]:3306/mvm?serverVersion=mariadb-10.11.0" >> .env.test.local
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Shutdown Ubuntu MySQL (SUDO)
run: sudo service mysql stop
- name: Set up MariaDB
uses: getong/[email protected]
with:
mysql database: mvm_test
mysql user: mvm
mysql password: password
- name: Build MVM
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
load: true
pull: true
tags: dhilsfu/mvm:latest
cache-from: type=registry,ref=dhilsfu/mvm:buildcache
cache-to: type=registry,ref=dhilsfu/mvm:buildcache,mode=max
- name: Run Unit Tests
run: |
docker run --rm \
-v "${GITHUB_WORKSPACE}/.env.test.local":/var/www/html/.env.test.local \
--network host \
dhilsfu/mvm:latest make test
deploy-image:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- unit-tests
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build & Push Symfony Base
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
pull: true
tags: dhilsfu/mvm:latest,dhilsfu/mvm:${{github.ref_name}}
cache-from: type=registry,ref=dhilsfu/mvm:buildcache
cache-to: type=registry,ref=dhilsfu/mvm:buildcache,mode=max
- name: Trigger Gitlab Deploy Job
run: |
curl -X POST \
--fail \
-F token=${{ secrets.GITLAB_CI_TOKEN }} \
-F "ref=main" \
-F "variables[APP_RELEASE_TAG]=${{github.ref_name}}" \
https://git.lib.sfu.ca/api/v4/projects/525/trigger/pipeline