-
Notifications
You must be signed in to change notification settings - Fork 4
122 lines (104 loc) · 3.39 KB
/
main.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
name: Unit Tests
on:
push:
branches:
- '*'
tags:
- '*'
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Configure sysctl limits
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
- name: Make .env.test.local
run: |
touch .env.test.local
echo DATABASE_URL="mysql://newn:password@127.0.0.1:3306/newn?serverVersion=mariadb-10.10.0" >> .env.test.local
echo ELASTICSEARCH_HOST="127.0.0.1" >> .env.test.local
echo ELASTICSEARCH_PORT="9200" >> .env.test.local
echo ELASTICSEARCH_USERNAME="elastic" >> .env.test.local
echo ELASTICSEARCH_PASSWORD="" >> .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/mariadb-action@v1.1
with:
mysql database: newn_test
mysql user: newn
mysql password: password
- name: Runs Elasticsearch
uses: getong/elasticsearch-action@v1.2
with:
elasticsearch version: '8.9.2'
host port: 9200
container port: 9200
host node port: 9300
node port: 9300
discovery type: 'single-node'
- name: Build newn
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
load: true
pull: true
tags: dhilsfu/newn:latest
cache-from: type=registry,ref=dhilsfu/newn:buildcache
cache-to: type=registry,ref=dhilsfu/newn: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/newn: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/newn:latest,dhilsfu/newn:${{github.ref_name}}
cache-from: type=registry,ref=dhilsfu/newn:buildcache
cache-to: type=registry,ref=dhilsfu/newn: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/542/trigger/pipeline