-
Notifications
You must be signed in to change notification settings - Fork 14
219 lines (188 loc) · 6.13 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
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
name: main
on:
push:
branches: ['main']
tags: ['*']
env:
IMAGE_NAME: bmltenabled/bmlt-root-server:latest
jobs:
test-php:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php:
- "8.0"
- "8.1"
- "8.2"
db:
- "10.2"
- "latest"
services:
mariadb:
image: mariadb:${{ matrix.db }}
ports:
- 3306
env:
MARIADB_USER: rootserver
MARIADB_PASSWORD: rootserver
MARIADB_DATABASE: rootserver
MARIADB_ROOT_PASSWORD: rootserver
options: --health-cmd="${{ (matrix.db == 'latest') && 'mariadb-admin' || 'mysqladmin' }} ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: checkout 🛒
uses: actions/checkout@v3
- name: php ${{ matrix.php }} 🐘
id: setup-php
uses: shivammathur/setup-php@2.22.0
with:
php-version: ${{ matrix.php }}
tools: composer:v2.4.1
- name: make composer 🎼
run: |
DEV=1 make composer
- name: make lint 🧹
run: |
make lint
- name: make test 🧪
env:
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
run: |
make test
- name: Send coverage data to codecov.io 📀
if: matrix.db == 'latest' && matrix.php == '8.1'
uses: codecov/codecov-action@v3.1.1
with:
files: src/coverage.xml
test-js:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
steps:
- name: checkout 🛒
uses: actions/checkout@v3
- name: node 16 ❇️
uses: actions/setup-node@v3.5.1
with:
node-version: 16
- name: make npm ♦️
run: |
make npm
- name: make lint-js 🧹
run: |
make lint-js
- name: make test-js 🧪
env:
LARAVEL_BYPASS_ENV_CHECK: '1'
run: |
make test-js
build:
runs-on: ubuntu-22.04
needs: [test-php, test-js]
permissions:
id-token: write
contents: write
steps:
- name: Checkout 🛒
uses: actions/checkout@v3
- name: php 8.0 🐘
id: setup-php
uses: shivammathur/setup-php@2.22.0
with:
php-version: '8.0'
tools: composer:v2.4.1
- name: make composer 🎼
run: |
make composer
- name: setup node 16 ❇️
uses: actions/setup-node@v3.5.1
with:
node-version: 16
- name: make frontend 🐥
run: |
make frontend
- name: make crouton 🍞
run: |
make crouton
- name: Write .env with APP_VERSION and COMMIT_SHA 🧃
shell: bash
run: |
echo COMMIT_SHA=${GITHUB_SHA} > src/.env
if [[ $GITHUB_REF_NAME =~ ^([0-9]+\.){2}(\*|[0-9]+)(-.*)?$ ]]; then
echo APP_VERSION=${GITHUB_REF_NAME} >> src/.env
fi
- name: make zip 🗜
run: |
make zip
- name: Configure S3 AWS Credentials 🪪
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions/gh-ci-s3-artifact
role-session-name: gh-actions
aws-region: us-east-1
- name: Copy Artifacts to S3 🪣
run: |
aws s3 cp build/bmlt-root-server.zip s3://${{ secrets.S3_BUCKET }}/bmlt-root-server/bmlt-root-server-$(cat src/config/app.php | grep "'version'" | cut -d"'" -f6)-build${GITHUB_RUN_NUMBER}-${GITHUB_SHA}.zip
- name: Configure AWS Credentials 🪪
if: contains(github.ref_name, 'main') || contains(github.ref_name, 'unstable')
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions/gh-ci-tf-bmlt-rs
role-session-name: gh-actions-bmlt
aws-region: us-east-1
- name: Login to Docker Hub 🎫
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: make docker 🐳
if: contains(github.ref_name, 'main') || contains(github.ref_name, 'unstable')
run: |
make docker
- name: make docker-push 🐋
if: contains(github.ref_name, 'main') || contains(github.ref_name, 'unstable')
id: docker_push_images
run: |
make docker-push
- name: Generate Release Notes 📝
if: github.ref_type == 'tag'
run: |
curl -LO https://raw.githubusercontent.com/bmlt-enabled/release-notes-tool/master/gh-release-notes.sh
chmod +x gh-release-notes.sh
./gh-release-notes.sh CHANGELOG.md "##"
RELEASE_TYPE=$(if [[ "$GITHUB_REF_NAME" =~ "beta" ]]; then echo "true"; else echo "false"; fi)
echo "RELEASE_TYPE=${RELEASE_TYPE}" >> $GITHUB_ENV
- name: Create Release 🎉
uses: ncipollo/release-action@v1.11.1
if: github.ref_type == 'tag'
with:
artifacts: "build/bmlt-root-server.zip"
bodyFile: "changelog.txt"
prerelease: ${{ env.RELEASE_TYPE }}
deploy:
runs-on: ubuntu-22.04
concurrency: deploy-${{ matrix.env }}
needs: [build]
permissions:
id-token: write
contents: write
if: contains(github.ref_name, 'main')
strategy:
fail-fast: false
matrix:
env:
- "latest"
- "unstable"
steps:
- name: Checkout 🛒
uses: actions/checkout@v3
- name: Configure AWS Credentials 🪪
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions/gh-ci-tf-bmlt-rs
role-session-name: gh-actions-bmlt
aws-region: us-east-1
- name: Update ECS Service bmlt-${{ matrix.env }} ⛴
run: |
aws ecs update-service --cluster bmlt --service bmlt-${{ matrix.env }} --force-new-deployment
aws ecs wait services-stable --cluster bmlt --services bmlt-${{ matrix.env }}