-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (104 loc) · 4.01 KB
/
deploy.yml
File metadata and controls
118 lines (104 loc) · 4.01 KB
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: Deploy to GCP
on:
push:
branches: [main]
workflow_dispatch:
inputs:
env:
description: Target environment
required: true
default: prod
type: choice
options: [prod, staging]
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
REGION: us-central1
REGISTRY: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/mockstack
IMAGE_TAG: ${{ github.sha }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
- uses: google-github-actions/setup-gcloud@v2
- run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
- name: Build and push chat-service
run: |
docker build -t ${{ env.REGISTRY }}/chat-service:${{ env.IMAGE_TAG }} \
-t ${{ env.REGISTRY }}/chat-service:latest \
./chat-service
docker push ${{ env.REGISTRY }}/chat-service:${{ env.IMAGE_TAG }}
docker push ${{ env.REGISTRY }}/chat-service:latest
- name: Build and push ai-service
run: |
docker build -t ${{ env.REGISTRY }}/ai-service:${{ env.IMAGE_TAG }} \
-t ${{ env.REGISTRY }}/ai-service:latest \
./ai-service
docker push ${{ env.REGISTRY }}/ai-service:${{ env.IMAGE_TAG }}
docker push ${{ env.REGISTRY }}/ai-service:latest
- name: Build and push workers
run: |
docker build -t ${{ env.REGISTRY }}/workers:${{ env.IMAGE_TAG }} \
-t ${{ env.REGISTRY }}/workers:latest \
./workers
docker push ${{ env.REGISTRY }}/workers:${{ env.IMAGE_TAG }}
docker push ${{ env.REGISTRY }}/workers:latest
- name: Build and push frontend
run: |
docker build -t ${{ env.REGISTRY }}/frontend:${{ env.IMAGE_TAG }} \
-t ${{ env.REGISTRY }}/frontend:latest \
--build-arg NG_ENV=production \
./frontend
docker push ${{ env.REGISTRY }}/frontend:${{ env.IMAGE_TAG }}
docker push ${{ env.REGISTRY }}/frontend:latest
run-migrations:
runs-on: ubuntu-latest
needs: build-and-push
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
- uses: google-github-actions/setup-gcloud@v2
- name: Run Alembic migrations via Cloud Run Job
run: |
gcloud run jobs execute alembic-migrate-${{ github.event.inputs.env || 'prod' }} \
--region ${{ env.REGION }} \
--wait \
--update-env-vars IMAGE_TAG=${{ env.IMAGE_TAG }}
deploy-services:
runs-on: ubuntu-latest
needs: run-migrations
permissions:
id-token: write
contents: read
steps:
- id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SA_EMAIL }}
- uses: google-github-actions/setup-gcloud@v2
- name: Deploy chat-service
run: |
gcloud run services update chat-service-${{ github.event.inputs.env || 'prod' }} \
--image ${{ env.REGISTRY }}/chat-service:${{ env.IMAGE_TAG }} \
--region ${{ env.REGION }}
- name: Deploy ai-service
run: |
gcloud run services update ai-service-${{ github.event.inputs.env || 'prod' }} \
--image ${{ env.REGISTRY }}/ai-service:${{ env.IMAGE_TAG }} \
--region ${{ env.REGION }}