-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (93 loc) · 3.68 KB
/
ci.yaml
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
name: ci
on:
push:
branches:
- main
jobs:
build-api:
runs-on: "ubuntu-latest"
steps:
- name: checkout
uses: actions/checkout@v2
- id: auth
name: authenticate with Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.GCLOUD_SERVICE_KEY }}"
service_account: registry-automation@${{ secrets.GCLOUD_PROJECT_ID }}.iam.gserviceaccount.com
access_token_lifetime: 300s
- name: set up Google Cloud SDK
uses: "google-github-actions/setup-gcloud@v1"
- name: configure Docker for GCP
run: gcloud auth configure-docker
- name: build @rimun/api
run: docker build -f Dockerfile.api . -t eu.gcr.io/${{ secrets.GCLOUD_PROJECT_ID }}/rimun-api:${{ github.sha }}
- name: push @rimun/api
run: docker push eu.gcr.io/${{ secrets.GCLOUD_PROJECT_ID }}/rimun-api:${{ github.sha }}
build-app:
runs-on: "ubuntu-latest"
steps:
- name: checkout
uses: actions/checkout@v2
- id: auth
name: authenticate with Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.GCLOUD_SERVICE_KEY }}"
service_account: registry-automation@${{ secrets.GCLOUD_PROJECT_ID }}.iam.gserviceaccount.com
access_token_lifetime: 300s
- name: set up Google Cloud SDK
uses: "google-github-actions/setup-gcloud@v1"
- name: configure Docker for GCP
run: gcloud auth configure-docker
- name: build @rimun/app
run: docker build -f Dockerfile.app . -t eu.gcr.io/${{ secrets.GCLOUD_PROJECT_ID }}/rimun-app:${{ github.sha }}
- name: push @rimun/app
run: docker push eu.gcr.io/${{ secrets.GCLOUD_PROJECT_ID }}/rimun-app:${{ github.sha }}
deploy:
needs: [build-api, build-app]
runs-on: "ubuntu-latest"
steps:
- id: auth
name: authenticate with Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.GCLOUD_SERVICE_KEY }}"
service_account: registry-automation@${{ secrets.GCLOUD_PROJECT_ID }}.iam.gserviceaccount.com
access_token_lifetime: 300s
- name: deploy @rimun/api
uses: google-github-actions/deploy-cloudrun@v1
with:
service: rimun-api
region: ${{ vars.GCLOUD_REGION }}
image: eu.gcr.io/${{ secrets.GCLOUD_PROJECT_ID }}/rimun-api:${{ github.sha }}
env_vars: |
SENTRY_DSN=${{ secrets.SENTRY_DSN }}
PASSWORD_RECOVERY_URL=${{ vars.PASSWORD_RECOVERY_URL }}
DATABASE_URL=${{ secrets.DATABASE_URL }}
MAIL_HOST=${{ vars.MAIL_HOST }}
MAIL_PORT=${{ vars.MAIL_PORT }}
MAIL_USERNAME=${{ secrets.MAIL_USERNAME }}
MAIL_PASSWORD=${{ secrets.MAIL_PASSWORD }}
FTP_HOST=${{ vars.FTP_HOST }}
FTP_USER=${{ secrets.FTP_USER }}
FTP_PASSWORD=${{ secrets.FTP_PASSWORD }}
JWT_SECRET=${{ secrets.JWT_SECRET }}
SECRET_KEY=${{ secrets.SECRET_KEY }}
MAIL_CONTACT_RECIPIENT=${{ vars.MAIL_CONTACT_RECIPIENT }}
- name: deploy @rimun/app
uses: google-github-actions/deploy-cloudrun@v1
with:
service: rimun-app
region: ${{ vars.GCLOUD_REGION }}
image: eu.gcr.io/${{ secrets.GCLOUD_PROJECT_ID }}/rimun-app:${{ github.sha }}
migrate:
needs: deploy
runs-on: "ubuntu-latest"
steps:
- name: checkout
uses: actions/checkout@v2
- name: node
uses: actions/setup-node@v3
- name: deploy
run: DATABASE_URL=${{ secrets.DATABASE_URL }} npx prisma migrate deploy