-
Notifications
You must be signed in to change notification settings - Fork 2
143 lines (133 loc) · 3.93 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
name: CI
on:
push:
branches: [master, dev]
pull_request:
branches: [master, dev]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm pnpx prisma generate
- run: pnpm lint
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm pnpx prisma generate
- run: pnpm build
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
env:
# Used for prisma generation
DATABASE_URL: mysql://test:test@localhost:3306/arena
services:
mariadb:
image: mariadb:10
env:
MYSQL_USER: test
MYSQL_PASSWORD: test
MYSQL_DATABASE: arena
MYSQL_RANDOM_ROOT_PASSWORD: yes
ports:
- 3306:3306
options: --name mariadb --health-cmd="mysqladmin ping" --health-interval=1s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm pnpx prisma generate
- run: pnpm pnpx prisma db push
- run: docker exec -i mariadb mysql -utest -ptest arena < seed.sql
- run: pnpm test:coverage
- uses: codecov/codecov-action@v1
deploy-dbdocs:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
needs:
- lint
- build
- test
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm pnpx prisma generate
- env:
BRANCH: ${{ github.ref == 'refs/heads/master' && 'master' || 'dev' }}
DBDOCS_TOKEN: ${{ secrets.DBDOCS_TOKEN }}
run: pnpm dbdocs build dbml/schema.dbml --project=${{ env.BRANCH }}
deploy:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev'
runs-on: ubuntu-latest
needs:
- lint
- build
- test
env:
RESOURCE_NAME: ${{ github.ref == 'refs/heads/master' && 'prod-api' || 'dev-api' }}
steps:
- uses: actions/checkout@v2
- name: Install oc
uses: redhat-actions/oc-installer@v1
with:
oc_version: '4.6'
- name: Login to OKD
run: oc login --token=${{ secrets.OKD_TOKEN }} --server=${{ secrets.OKD_SERVER }}
- name: Change the project
run: oc project ${{ secrets.OKD_PROJECT }}
- name: Start the build
run: oc start-build ${{ env.RESOURCE_NAME }} --follow
- uses: lazy-actions/slatify@master
if: always()
with:
type: ${{ job.status }}
job_name: '*Deployment to ${{ env.RESOURCE_NAME }}*'
commit: true
url: ${{ secrets.SLACK_WEBHOOK_URL }}
token: ${{ secrets.GITHUB_TOKEN }}