-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (114 loc) · 3.61 KB
/
default.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
name: Default
on:
push:
branches: [master]
pull_request:
jobs:
check:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15.2-alpine
env:
POSTGRES_USER: serieslist
POSTGRES_PASSWORD: serieslist
POSTGRES_DB: serieslist_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'master'
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'pnpm'
- name: Setup
run: |
cp .env.example .env
bash bin/generate-secret-token.sh
- name: Installing dependencies
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
run: |
pnpm install
pnpm exec nx affected -t install-deps:e2e
- name: Checks
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
run: |
pnpm exec nx affected -t migrate:test
pnpm exec nx affected -t migrate:e2e
pnpm exec nx affected -t lint,tsc,test:coverage --verbose
- name: E2E tests
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
run: |
pnpm exec nx affected -t test:e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: apps/e2e/playwright-report/
retention-days: 30
deploy:
runs-on: ubuntu-latest
environment:
name: production
url: https://serieslist.joosep.xyz
needs: check
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: nrwl/nx-set-shas@v3
with:
main-branch-name: 'master'
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'pnpm'
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Setup
run: |
cp .env.example .env
pnpm install
- name: Build containers
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
sed -i.bak -e "s/VITE_API_URL=.*/VITE_API_URL=https:\/\/api.serieslist.joosep.xyz/" .env
pnpm exec nx affected -t build:docker
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOYMENT_SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.DEPLOYMENT_SSH_HOST }} >> ~/.ssh/known_hosts
- name: Updating deployment in server
run: bash bin/update-deployment.sh
env:
DEPLOYMENT_SSH_HOST: ${{ secrets.DEPLOYMENT_SSH_HOST }}
DEPLOYMENT_SSH_USER: ${{ secrets.DEPLOYMENT_SSH_USER }}