-
-
Notifications
You must be signed in to change notification settings - Fork 1
193 lines (179 loc) Β· 6.29 KB
/
publish.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
name: Publish
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.ref }}
on:
push:
branches:
- '*'
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
build-lint-test-docker:
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: 'postgres:alpine'
# Provide the password for postgres
env:
POSTGRES_USER: prisma_user
POSTGRES_PASSWORD: CHANGE_ME_PLEASE_OR_I_WILL_CRY
POSTGRES_DB: prisma
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
# redis:
# # Docker Hub image
# image: redis:alpine
# # Set health checks to wait until redis has started
# options: >-
# --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
# ports:
# # Maps port 6379 on service container to the host
# - 6379:6379
steps:
- name: Check out current repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Restore backend build from cache
if: ${{ !github.event.act }}
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/backend/dist
${{ github.workspace }}/**/tsconfig.tsbuildinfo
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-backend-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('backend/src/**.[jt]s?', 'backend/src/**.json') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-backend-${{ hashFiles('**/pnpm-lock.yaml') }}-
# see https://github.com/vercel/next.js/pull/27362
- name: Restore frontend build from cache
if: ${{ !github.event.act }}
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/frontend/.next/cache
${{ github.workspace }}/.cache
~/.cache
${{ github.workspace }}/**/tsconfig.tsbuildinfo
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-frontend-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('frontend/src/**.[jt]sx?', 'frontend/src/**.json') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-frontend-${{ hashFiles('**/pnpm-lock.yaml') }}-
- name: π₯ Monorepo install all deps & pnpm
uses: ./.github/actions/pnpm-install
# - name: Create and seed test database
# working-directory: backend
# run: |
# pnpm exec prisma db push
# pnpm exec prisma db seed
# env:
# PRISMA_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/auth-backend?schema=public
- name: ποΈ Ensure Code is Linted
run: |
pnpm lint:check
- name: π§ Ensure Code is Formatted
run: |
pnpm format:check
- name: π Rename .env.example to .env
run: |
mv .env.example .env
- name: πββοΈ Copy .env to backend
run: |
cp .env backend/.env
- name: π€ Build Project
run: |
pnpm build
- name: π³ Build Docker Image
run: |
docker compose up --build
env:
NODE_ENV: production
- name: π₯³ Run Tests (project-wide)
run: |
pnpm test
- name: π€ Upload Code coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ !github.event.act }}
- uses: actions/upload-artifact@v3
if: ${{ !github.event.act }}
with:
name: cypress-screenshots
path: ./frontend/cypress/screenshots
- uses: actions/upload-artifact@v3
if: ${{ !github.event.act }}
with:
name: cypress-videos
path: ./frontend/cypress/videos
- uses: actions/upload-artifact@v3
if: ${{ !github.event.act }}
with:
name: build
path: |
./frontend/.next
./frontend/out
./frontend/public
- uses: actions/upload-artifact@v3
if: ${{ !github.event.act }}
with:
name: Backend Build
path: ./backend/dist
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [build-lint-test-docker]
if: ${{ !github.event.act }} && github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: π₯ Monorepo install all deps & pnpm
uses: ./.github/actions/pnpm-install
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: false
git_push_gpgsign: false
- name: π Publish to the great interwebs.
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_NAME: ${{ steps.import_gpg.outputs.name }}
GIT_AUTHOR_EMAIL: ${{ steps.import_gpg.outputs.email }}
GIT_COMMITTER_NAME: ${{ steps.import_gpg.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.import_gpg.outputs.email }}
signingKeyId: ${{ steps.import_gpg.outputs.keyid }}
signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
signingPassword: ${{ secrets.PASSPHRASE }}
GH_URL: 'https://api.github.com/'
run: |
pnpm semantic-release