-
Notifications
You must be signed in to change notification settings - Fork 3
138 lines (122 loc) · 3.59 KB
/
lab-server.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
name: Lab Server
on:
push:
paths:
- '.github/workflows/lab-server.yml'
- 'yarn.lock'
- 'lab-server/**'
defaults:
run:
working-directory: ./lab-server
env:
PORT: 8081
KEYCLOAK_AUTH_SERVER_URL: ${{ secrets.KEYCLOAK_AUTH_SERVER_URL }}
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
KEYCLOAK_CLIENT_ID: ${{ secrets.KEYCLOAK_CLIENT_ID }}
KEYCLOAK_SECRET: ${{ secrets.KEYCLOAK_SECRET }}
DB_HOST: postgres
DB_PORT: 5432
DB_USER: postgres
DB_PASS: postgres
DB_NAME: lab_server_db
MINIO_PORT: 9000
MINIO_ENDPOINT: minio
MINIO_ROOT_USER: admin_minio
MINIO_ROOT_PASSWORD: admin_minio
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn lint
test-e2e:
name: Test E2E
runs-on: ubuntu-latest
container:
image: node:18-buster-slim
services:
minio:
# we refrain from using the official minio image as we would need to
# pass an additional `server` sub-command to the container. Currently,
# GH-actions does not support this. Note that this is not an official
# minio image and should therefore not be used in production
# environments. See: https://stackoverflow.com/questions/60849745/
image: bitnami/minio
postgres:
image: postgres
env:
POSTGRES_USER: ${{ env.DB_USER }}
POSTGRES_PASSWORD: ${{ env.DB_PASS }}
POSTGRES_DB: ${{ env.DB_NAME }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- run: yarn
- run: cp test/helpers/e2e-users.json src/seeder/users.json
- run: yarn seed:run
- run: yarn test:e2e:cov
- uses: actions/upload-artifact@v3
with:
name: coverage-report
path: lab-server/coverage
codecov:
name: Generate Code Coverage Report
needs: [test-e2e]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: coverage-report
path: lab-server/coverage
- uses: codecov/codecov-action@v2
with:
flags: lab-server
directory: lab-server/coverage
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn build
build-and-push-image:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [lint, test-e2e, build]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-lab-server
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create empty .env file (expected by Dockerfile)
run: cp .env.example .env
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./lab-server/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}