This repository has been archived by the owner on May 29, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
229 lines (221 loc) · 7.74 KB
/
master.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
220
221
222
223
224
225
226
227
name: Deploy to Production
on:
push:
branches:
- master
concurrency:
group: master
cancel-in-progress: true
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_BRANCH: ${{ github.ref }}
NX_RUN_GROUP: $${{ github.run_id }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
DATABASE_URL: "postgres://postgres:postgres@localhost:5432/baneverywhere-testing?schema=public"
jobs:
build:
runs-on: ubuntu-latest
environment:
name: production
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps TCP port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v2
id: npm-cache
with:
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
/tmp/.buildx-cache-api
/tmp/.buildx-cache-proxy
restore-keys: |
${{ runner.os }}-npm-
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: 'master'
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16.13
- run: git fetch origin master
- run: npm ci
- run: npm run generate
- run: npx prisma migrate deploy
- run: npx nx-cloud start-ci-run
- name: Run tests
run: NX_CLOUD_DISTRIBUTED_EXECUTION=false npx nx run-many --target=test --all --parallel=false --coverage --coverage-reporters=lcov,json-summary
- run: npx coverage-badges
- run: npx nx run-many --target=build --all --configuration=production --parallel --max-parallel=2
- run: npx nx-cloud stop-all-agents
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: rgolea
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push API Image
id: docker_build_api
uses: docker/build-push-action@v2
with:
file: ./config/docker/api.Dockerfile
push: true
tags: rgolea/baneverywhere-api:latest
context: .
cache-from: type=local,src=/tmp/.buildx-cache-api
cache-to: type=local,dest=/tmp/.buildx-cache-api-new,mode=max
- name: Build and push Migration Image
id: docker_build_migration
uses: docker/build-push-action@v2
with:
file: ./config/docker/migration.Dockerfile
push: true
tags: rgolea/baneverywhere:latest
context: .
cache-from: type=local,src=/tmp/.buildx-cache-api
cache-to: type=local,dest=/tmp/.buildx-cache-api-new,mode=max
- name: Build and push Online Checker Image
id: docker_build_online_checker
uses: docker/build-push-action@v2
with:
file: ./config/docker/online-checker.Dockerfile
push: true
tags: rgolea/baneverywhere-online-checker:latest
context: .
cache-from: type=local,src=/tmp/.buildx-cache-api
cache-to: type=local,dest=/tmp/.buildx-cache-api-new,mode=max
- name: Build and push Queue Processor Image
id: docker_build_queue_processor
uses: docker/build-push-action@v2
with:
file: ./config/docker/queue-processor.Dockerfile
push: true
tags: rgolea/baneverywhere-queue-processor:latest
context: .
cache-from: type=local,src=/tmp/.buildx-cache-api
cache-to: type=local,dest=/tmp/.buildx-cache-api-new,mode=max
- name: Build and push Bot Image
id: docker_build_bot
uses: docker/build-push-action@v2
with:
file: ./config/docker/bot.Dockerfile
push: true
tags: rgolea/baneverywhere-bot:latest
context: .
cache-from: type=local,src=/tmp/.buildx-cache-api
cache-to: type=local,dest=/tmp/.buildx-cache-api-new,mode=max
- name: Build and push Proxy Image
id: docker_build_proxy
uses: docker/build-push-action@v2
with:
file: ./config/docker/nginx.Dockerfile
push: true
tags: rgolea/baneverywhere-proxy:latest
context: .
cache-from: type=local,src=/tmp/.buildx-cache-proxy
cache-to: type=local,dest=/tmp/.buildx-cache-proxy-new,mode=max
-
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache-api
rm -rf /tmp/.buildx-cache-proxy
mv /tmp/.buildx-cache-api-new /tmp/.buildx-cache-api
mv /tmp/.buildx-cache-proxy-new /tmp/.buildx-cache-proxy
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: 22
script: |
cd /app
docker-compose down
docker system prune -af
rm -rf docker-compose.yml
wget https://raw.githubusercontent.com/rgolea/baneverywhere/master/docker-compose.yml --no-cache --no-dns-cache
docker-compose up -d
- name: Deploy to GH Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./coverage
release:
runs-on: ubuntu-latest
steps:
- name: set env
run: echo "NOW=v.$(date +'%Y%m%d.%H%M%S')" >> $GITHUB_ENV
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Bump version and push tag
id: bump-version
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: ${{ github.ref_name }}-${{ env.NOW }}
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
# Drafts your next Release notes as Pull Requests are merged into "master"
- name: Draft Release notes
id: draft-release-notes
uses: release-drafter/release-drafter@v5
if: github.ref == 'refs/heads/master'
with:
config-name: release-drafter.yml
publish: false
tag: ${{ steps.bump-version.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
agents:
runs-on: ubuntu-latest
name: Nx Agent ${{ matrix.agent }}
timeout-minutes: 60
strategy:
matrix:
agent: [ 1, 2, 3 ]
steps:
- name: Cache node modules
uses: actions/cache@v2
id: npm-cache
with:
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
path: |
**/node_modules
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16.13
- run: npm ci
- name: Start Nx Agent ${{ matrix.agent }}
run: npx nx-cloud start-agent