-
Notifications
You must be signed in to change notification settings - Fork 5
141 lines (117 loc) · 4.29 KB
/
deploy.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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 --release
# Verify build success
if [ ! -d "build/web" ]; then
echo "Error: build/web directory does not exist"
exit 1
fi
echo "Flutter Web build completed successfully."
- name: Upload Build 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: Download Flutter Web Build Artifact
uses: actions/download-artifact@v3
with:
name: flutter-web-build
path: flutter-web-build
- name: Verify Downloaded Artifact
run: |
echo "Verifying downloaded artifact..."
ls -la # This will show the current directory's contents
ls -la flutter-web-build || echo "flutter-web-build directory doesn't exist" # Added check for existence of the directory
- name: Prepare Build Context
run: |
mkdir -p build/web
cp -r flutter-web-build/* build/web # Copy files from the downloaded artifact to the build/web folder
echo "Build context prepared:"
ls -la build/web # Verify the files are in the build/web directory
- name: Authenticate to GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Configure Docker Authentication
run: |
gcloud auth configure-docker us-central1-docker.pkg.dev
- name: Build Docker Image for API
run: |
docker build \
-t us-central1-docker.pkg.dev/government-assistant-001/government-assistant-docker-repo/government-assistant-api \
-f Dockerfile .
- name: Build Docker Image for Flutter Web App
run: |
docker build \
-t us-central1-docker.pkg.dev/government-assistant-001/government-assistant-docker-repo/flutter-web-app \
-f Dockerfile.web .
- name: Verify Files in Docker Image
run: |
docker run us-central1-docker.pkg.dev/government-assistant-001/government-assistant-docker-repo/flutter-web-app ls -l /usr/share/nginx/html
- name: Push Docker Images
run: |
docker push us-central1-docker.pkg.dev/government-assistant-001/government-assistant-docker-repo/government-assistant-api
docker push us-central1-docker.pkg.dev/government-assistant-001/government-assistant-docker-repo/flutter-web-app
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: Deploy API to Cloud Run
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
- name: Deploy Flutter Web App to Cloud Run
run: |
gcloud run deploy flutter-web-app \
--image us-central1-docker.pkg.dev/government-assistant-001/government-assistant-docker-repo/flutter-web-app \
--platform managed \
--region us-central1 \
--allow-unauthenticated