-
Notifications
You must be signed in to change notification settings - Fork 8
217 lines (178 loc) · 5.65 KB
/
cd.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
name: 'CD'
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
check:
name: Check Is Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Expose git commit information
uses: rlespinasse/git-commit-data-action@v1.x
- name: Parse data
id: parse
run: |
echo "is_release=${{ startsWith(env.GIT_COMMIT_MESSAGE_SUBJECT, 'Release ') }}" >> $GITHUB_OUTPUT
echo "version=$(echo ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }} | sed -r 's/Release //')" >> $GITHUB_OUTPUT
echo "tag=$(echo ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }} | sed -r 's/Release /v/')" >> $GITHUB_OUTPUT
outputs:
is_release: ${{ steps.parse.outputs.is_release }}
version: ${{ steps.parse.outputs.version }}
tag: ${{ steps.parse.outputs.tag }}
commit_message: ${{ env.GIT_COMMIT_MESSAGE_SUBJECT }}
commit_body: ${{ env.GIT_COMMIT_MESSAGE_BODY }}
test-postgres:
name: Testing (Postgres)
needs: common-tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_DB: artgen
POSTGRES_USER: artgen
POSTGRES_PASSWORD: artgen
TZ: UTC
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install the interpreter
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: yarn
- name: Install development dependencies
run: yarn install --ignore-engines
- name: Run tests (PostgreSQL)
run: yarn test
env:
ARTGEN_DATABASE_DSN: postgres://artgen:artgen@localhost:5432/artgen
common-tests:
name: Common Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install the interpreter
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: yarn
- name: Install development dependencies
run: yarn install --ignore-engines
- name: Run type checking
run: yarn test:type
- name: Run tests (Common)
run: yarn test
env:
ARTGEN_DATABASE_DSN: "sqlite::memory:"
release-npm:
name: GPR / NPM release
runs-on: ubuntu-latest
needs:
- check
- test-postgres
if: ${{ success() && needs.check.outputs.is_release == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install the interpreter
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: yarn
- name: Install development dependencies
run: yarn install --ignore-engines
- name: Run build
run: yarn build
- name: Publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
check-version: false
- name: Publish to GPR
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
check-version: false
registry: 'https://npm.pkg.github.com'
release-docker:
name: Docker release
runs-on: ubuntu-latest
needs:
- check
- test-postgres
if: ${{ success() && needs.check.outputs.is_release == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Log in to the docker registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v3
with:
context: .
push: true
# platforms: linux/amd64,linux/arm64
tags: artgenio/core:latest,artgenio/core:${{ needs.check.outputs.version }}
release-gh:
name: GitHub release
runs-on: ubuntu-latest
needs:
- check
- test-postgres
if: ${{ success() && needs.check.outputs.is_release == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create git tag
uses: negz/create-tag@v1
with:
version: ${{ needs.check.outputs.tag }}
message: ${{ needs.check.outputs.commit_message }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create GH release
id: release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.check.outputs.version }}
body:
"**Automated release ${{ needs.check.outputs.commit_message }}** by GitHub Actions <3\n\n
${{ needs.check.outputs.commit_body }}\n
Docker install ```docker run -p 80:7200 artgenio/core:${{ needs.check.outputs.version }}```
"
tag_name: ${{ needs.check.outputs.tag }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
upload_url: ${{ steps.release.outputs.upload_url }}
url: ${{ steps.release.outputs.url }}
# # The demo is the latest released version
# deploy-demo:
# name: Deploy demo to Heroku
# runs-on: ubuntu-latest
# needs:
# - common-tests
# if: ${{ success() }}
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - uses: akhileshns/heroku-deploy@v3.12.12
# with:
# heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
# heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
# heroku_email: ${{ secrets.HEROKU_EMAIL }}