forked from nesistor/GovAssist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployment.yaml
115 lines (94 loc) · 3.08 KB
/
deployment.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
name: CI/CD Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.0'
- name: Build Flutter Web App
run: |
cd app
flutter pub get
flutter build web
# Verify if the build/web directory exists after the build
if [ ! -d "build/web" ]; then
echo "Error: build/web directory does not exist"
exit 1
fi
echo "Flutter Web build completed successfully, build/web directory exists."
- name: Upload build/web as artifact
uses: actions/upload-artifact@v3
with:
name: flutter-web-build
path: app/build/web
docker-build-push:
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Authenticate to GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Configure Docker
run: |
gcloud auth configure-docker us-central1-docker.pkg.dev
- name: Build Docker image for government-assistant-api
run: |
docker build -t us-central1-docker.pkg.dev/government-assistant-001/government-assistant-docker-repo/government-assistant-api -f Dockerfile .
- name: Push Docker images
run: |
docker push us-central1-docker.pkg.dev/government-assistant-001/government-assistant-docker-repo/government-assistant-api
deploy:
runs-on: ubuntu-latest
needs: docker-build-push
permissions:
contents: read
id-token: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Authenticate to GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Download flutter-web-build artifact
uses: actions/download-artifact@v3
with:
name: flutter-web-build
path: flutter-web-build
- name: List downloaded files
run: |
ls -R flutter-web-build
- name: Deploy Flutter Web App to Google Cloud Storage
run: |
gcloud storage cp -r flutter-web-build/* gs://web-flutter-gov-bucket/
- name: Deploy to Cloud Run (government-assistant-api)
env:
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
run: |
gcloud run deploy government-assistant-api \
--image us-central1-docker.pkg.dev/government-assistant-001/government-assistant-docker-repo/government-assistant-api \
--platform managed \
--region us-central1 \
--allow-unauthenticated \
--update-env-vars XAI_API_KEY=$XAI_API_KEY