-
Notifications
You must be signed in to change notification settings - Fork 1
executable file
·170 lines (158 loc) · 5.53 KB
/
main.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
name: Authier monorepo CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
name: runs typescript, tests, and deploys
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: authier
POSTGRES_PASSWORD: auth133r
POSTGRES_USER: authier
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--user root
redis:
image: redis
ports:
- 6379:6379
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
APPNAME: authier-api
AWS_REGION: eu-central-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
DIRECT_URL: ${{ secrets.DIRECT_URL }}
SHADOW_DATABASE_URL: ${{ secrets.SHADOW_DATABASE_URL }}
ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
REFRESH_TOKEN_SECRET: ${{ secrets.REFRESH_TOKEN_SECRET }}
COOKIE_SECRET: ${{ secrets.COOKIE_SECRET }}
FREE_GEOIP_API_KEY: ${{ secrets.FREE_GEOIP_API_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
MJ_APIKEY_PUBLIC: ${{ secrets.MJ_APIKEY_PUBLIC }}
MJ_APIKEY_PRIVATE: ${{ secrets.MJ_APIKEY_PRIVATE }}
STRIPE_ENDPOINT: ${{ secrets.STRIPE_ENDPOINT }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
REDIS_URL: ${{ secrets.REDIS_URL }}
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
IP_API_IO_API_KEY: ${{ secrets.IP_API_IO_API_KEY }}
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
FIREBASE_PRIVATE_KEY: ${{ secrets.FIREBASE_PRIVATE_KEY }}
FIREBASE_CLIENT_EMAIL: ${{ secrets.FIREBASE_CLIENT_EMAIL }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: |
pnpm i ts-node zx -g
pnpm i --frozen-lockfile --prefer-offline
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
backend:
- 'backend/**'
- '.github/**'
- 'pnpm-lock.yaml'
webExtension:
- 'web-extension/**'
- '.github/**'
- 'pnpm-lock.yaml'
mobileApp:
- 'mobile-app/**'
- '.github/**'
- 'pnpm-lock.yaml'
- name: schema gen
working-directory: ./backend
if: steps.changes.outputs.backend == 'true' || steps.changes.outputs.mobileApp == 'true'
run: |
pnpm gen
- name: backend install deps, check TS and run tests
working-directory: ./backend
if: steps.changes.outputs.backend == 'true'
env:
DATABASE_URL: postgresql://authier:auth133r@localhost:5432/authier
REDIS_URL: redis://localhost:6379
NODE_ENV: test
run: |
pnpm tsc
cp .env.sample .env
pnpm test:prepare
pnpm test
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
if: github.ref == 'refs/heads/main' && steps.changes.outputs.backend == 'true'
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: 'eu-central-1'
- name: backend build and deploy
working-directory: ./backend
if: github.ref == 'refs/heads/main' && steps.changes.outputs.backend == 'true'
env:
NODE_ENV: production
run: |
pnpm prisma:deploy
pnpm cdkDeploy
## TODO fix sentry release action
# - name: Create a Sentry.io release
# uses: tclindner/[email protected]
# if: steps.changes.outputs.backend == 'true'
# env:
# SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
# SENTRY_ORG: authier-ml
# SENTRY_PROJECT: authier-backend
# with:
# tagName: ${{ github.sha }}
# environment: production
- name: web-extension, check TS and run tests
working-directory: ./web-extension
if: steps.changes.outputs.webExtension == 'true' || steps.changes.outputs.backend == 'true'
run: |
pnpm tsc
# - name: Install Playwright Browsers & Run Playwright tests with backend
# if: steps.changes.outputs.backend == 'true'
# working-directory: ./web-extension
# run: |
# npx playwright install --with-deps
# xvfb-run --auto-servernum -- pnpm playwright:run
#
# - name: Upload test results
# if: always()
# uses: actions/upload-artifact@v4
# with:
# name: test-results
# path: web-extension/test-results
# retention-days: 30
- name: mobile-app, check TS and run tests
working-directory: ./mobile-app
if: steps.changes.outputs.mobileApp == 'true'
run: |
pnpm tsc
pnpm test