-
Notifications
You must be signed in to change notification settings - Fork 5
171 lines (145 loc) · 4.88 KB
/
ci.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
name: CI
on:
pull_request:
push:
branches: [main]
tags: ["**"]
workflow_dispatch:
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
env:
EMAIL_RATE_LIMIT: 3600
MATCHER_MAX_CAPACITY: 80
MYSQL_DATABASE: test_econ
MYSQL_ROOT_PASSWORD: password
services:
database-root:
image: mariadb:10.6
env:
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
database-tenant:
image: mariadb:10.6
env:
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }}
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }}
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build and test with Docker
uses: addnab/docker-run-action@v3
env:
DATABASE_URL: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@database-root:3306/${{ env.MYSQL_DATABASE }}
DATABASE_URL_TENANT_TEST: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@database-tenant:3306/${{ env.MYSQL_DATABASE }}
SIHL_ENV: test
SMTP_SENDER: [email protected]
TEST_EMAIL: [email protected]
with:
image: ocaml/opam:debian-10-ocaml-4.14
options: -v ${{ github.workspace }}:/app -w /app -e DATABASE_URL -e DATABASE_URL_TENANT_TEST -e TEST_EMAIL -e SMTP_SENDER -e SIHL_ENV
run: |
# Reclaim required directory permissions
sudo chown -R opam .
# Build and test executable
/app/scripts/build.sh || exit 1
# Restore directory permissions to avoid conflicts
sudo chown -R 1001:123 .
- uses: actions/upload-artifact@v3
with:
name: run.exe
path: _build/default/pool/run/run.exe
- uses: actions/upload-artifact@v3
if: failure()
with:
name: tests
path: _build/default/pool/test/
- name: Notify about failure
if: failure()
uses: ./.github/actions/notify-failure
with:
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }}
assets:
name: Build assets
if: github.repository == 'uzh/pool'
runs-on: ubuntu-latest
container:
image: node:lts
env:
ECON_PACKAGE_REGISTRY_READ_TOKEN: ${{ secrets.ECON_PACKAGE_REGISTRY_READ_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: install yarn packages
run: yarn install
- name: build yarn package
run: yarn build
- name: move all assets to one folder
run: '[ "$(ls pool/public)" ] && cp -r pool/public/* public || exit 0'
- uses: actions/upload-artifact@v3
with:
name: assets
path: public
- name: Notify about failure
if: failure()
uses: ./.github/actions/notify-failure
with:
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }}
deploy_staging:
name: Trigger staging deploy
runs-on: ubuntu-latest
needs: [build, assets]
if: github.ref_name == 'main'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Trigger deploy
uses: ./.github/actions/trigger-deploy
with:
url: ${{ secrets.ECON_DEPLOY_TRIGGER_URL }}
token: ${{ secrets.ECON_DEPLOY_TRIGGER_TOKEN }}
release:
name: Release a new version
runs-on: ubuntu-latest
needs: [build, assets]
if: github.ref_type == 'tag'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
- name: Extract version changelog
run: sed -nr "/^## .?v?${GITHUB_REF_NAME}/,/^## /p" CHANGELOG.md | sed '1d;2d;$d' > changes.md
- name: Compress assets
run: |
tar -zcf assets.tar.gz assets
tar -zcf executable.tar.gz run.exe/run.exe
- name: Create release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
body_path: changes.md
files: |
assets.tar.gz
executable.tar.gz
- name: Notify about failure
if: failure()
uses: ./.github/actions/notify-failure
with:
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }}
deploy_production:
name: Trigger production deploy
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Trigger deploy
uses: ./.github/actions/trigger-deploy
with:
url: ${{ secrets.ECON_DEPLOY_TRIGGER_URL }}
token: ${{ secrets.ECON_DEPLOY_TRIGGER_TOKEN }}
target: production