forked from TFNS/CTFNote
-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (93 loc) · 2.78 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
name: Continuous Integration
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: ctfnote
POSTGRES_USER: ctfnote
ports:
- 5432:5432
strategy:
fail-fast: false
matrix:
node: [20, 19, 18]
name: Node.js ${{ matrix.node }} build
steps:
- uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: "yarn"
cache-dependency-path: |
api/yarn.lock
front/yarn.lock
- name: Build api
working-directory: ./api
run: |
yarn install --immutable --immutable-cache --check-cache
yarn build
yarn run pg-validate-migrations ./migrations
- name: Build frontend
working-directory: ./front
run: |
yarn install --immutable --immutable-cache --check-cache
yarn build
- name: Run database migrations and codegen
env:
PAD_CREATE_URL: http://hedgedoc:3000/new
PAD_SHOW_URL: /
DB_DATABASE: ctfnote
DB_ADMIN_LOGIN: ctfnote
DB_ADMIN_PASSWORD: ctfnote
DB_USER_LOGIN: user_postgraphile
DB_USER_PASSWORD: secret_password
DB_HOST: 127.0.0.1
DB_PORT: 5432
WEB_PORT: 3000
run: |
cd ./api
# create database tables first, running migrations
DB_MIGRATE_ONLY=1 yarn start
# then start the api backend server
nohup yarn start &
cd ../front
# and finally validate the generated files are up to date
bash ../api/start.sh 127.0.0.1 3000 yarn run graphql-codegen --config codegen.yml --check
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- uses: actions/checkout@v4
- name: Set up Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: "yarn"
cache-dependency-path: |
api/yarn.lock
front/yarn.lock
- name: Install frontend dependencies
working-directory: ./front
run: yarn install --immutable --immutable-cache --check-cache
- name: Lint frontend
working-directory: ./front
run: |
yarn run eslint --ext .js,.ts,.vue,.graphql ./src
yarn run prettier --check 'src/**/*.{ts,js,vue,graphql}'
- name: Install api dependencies
working-directory: ./api
run: yarn install --immutable --immutable-cache --check-cache
- name: Lint api
working-directory: ./api
run: |
yarn run eslint --ext .ts ./src
yarn run prettier --check 'src/**/*.ts'