-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Deployment Validation Failure and Improve Robustness #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
386642e
7d23f59
d89f246
1fb70d0
3e2dde1
d5f3fba
720d10e
47eb30e
b40447a
c17464c
290832f
5013b2e
2e92094
ab76e41
98b8743
321b851
4d285f8
51376bc
f1c5785
befba9a
109e03d
4f97a83
3d03318
3949d07
ffd6bad
6f66223
ab01548
7786604
2adb8db
3a4c182
15da2c8
14d08a3
60748fe
74fb952
16079a8
5f724ce
8243e07
e78cc7c
17b986f
fa941a8
21a4dca
7a3bf70
61723d8
3bf603c
0fc41a5
c83f865
f328056
b9d60be
97c1a97
7478d47
97b2f98
3bb0a52
83b9b3d
1cbce3c
18dd79e
6bb97bc
2941387
8a1edd4
66a7f85
de40dad
60a6a98
942d28f
33d5081
99e3635
7203de9
3ced7a1
29a8a13
4ddef4f
739496e
784db47
307c9c2
6609d99
9df89ed
dff9adf
c385f66
522e971
97a1972
22bb540
30165ef
146c974
50643c1
8d05ce0
fb7a7af
aae286c
80fc8e2
a125c6b
792cfc1
5d6642f
2c72978
01eaf5b
563e0d4
5f67f42
3c46c98
0da35ff
1d9e37c
bb1cfad
38744b8
81ffc54
a078bf4
44c3a16
ffe9604
abd4f66
526a878
7b52b79
173f26a
05d6ceb
6396ad9
10abe20
bd6694c
8a83f8f
0f4cb73
8b88dc7
cf14688
282442f
017df8a
dd91ffc
e5d935d
17012b1
98123c9
d4f13de
4919538
e34957c
95d88f5
11b13aa
0000615
10530c0
5fc42ff
939f47a
ef026d0
5663020
813614d
47cea25
fc10b60
909669b
85a2bf8
cd03fea
5ab764a
215fc82
31316f1
5137444
de4211d
f6a271f
639118a
6928d58
3426d45
07013df
2553c4b
8f79614
fd53faf
2820afd
03be17c
22758b3
a04c40f
cb8843f
94d83b8
6e37b3a
d2c0591
69521ed
030cbd5
ad75965
db4c58a
de7e177
5fbaba0
f21dcd0
bc2922d
59a1eec
1a10084
f1c9400
fd2d014
9006948
675f461
136376a
62f83d6
ec78712
f3b8edb
27b99fb
cea7d5f
d37c451
68fcab0
748bc66
0371919
c754051
3faa42f
e540718
e08a6e3
d4fcb2f
f470fdd
3b2488f
132c740
d84425f
696a63e
6c57341
3e4e662
6608040
07eaf3c
f7d88fd
4561857
5b2ba64
0248ced
58e5a0e
01846ab
5af180f
597cb9d
666ef31
df9380a
28434b3
093ae75
6c12a95
b332fe6
d9314c6
d5ac43e
f893f92
2837470
902e6f8
f5aa226
43449e4
727b5a2
08bb618
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| # Copyright (c) 2026 Frank Currie (frank@sfle.ca) | ||
|
|
||
| .gcloudignore | ||
| .git | ||
| .gitignore | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| <!-- Copyright (c) 2026 Frank Currie (frank@sfle.ca) --> | ||
| # Known Issues | ||
|
|
||
| All issues have been logged in the GitHub repository. Please refer to the [Issues page](https://github.com/fkcurrie/utba-swarmmap/issues) for the latest updates and details. | ||
| All issues have been logged in the GitHub repository. Please refer to the [Issues page](https://github.com/fkcurrie/utba-swarmmap/issues) for the latest updates and details. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| # Copyright (c) 2026 Frank Currie (frank@sfle.ca) | ||
| --- | ||
| name: Deploy to Cloud Run | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| tags: | ||
| - 'v*' | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| PROJECT_ID: utba-swarmmap | ||
| REGION: northamerica-northeast2 | ||
| SERVICE: utba-swarmmap-backend | ||
| FRONTEND_SERVICE: utba-swarmmap-frontend | ||
| REPO: swarmmap-repo | ||
| GCS_BUCKET_NAME: utba-swarmmap-media | ||
|
|
||
| jobs: | ||
| deploy: | ||
| name: Validate, Build, and Deploy | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| issues: write | ||
|
|
||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: '24' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install Dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Linting | ||
| run: | | ||
| npx eslint "frontend/static/js/**/*.js" | ||
| npx markdownlint "**/*.md" --ignore node_modules | ||
|
|
||
| - name: YAML Lint | ||
| uses: ibiqlik/action-yamllint@v3 | ||
| with: | ||
| file_or_dir: . | ||
| config_file: .yamllint.yaml | ||
|
|
||
| - name: Commitlint | ||
| uses: wagoid/commitlint-github-action@v6 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version-file: backend/go.mod | ||
| cache-dependency-path: backend/go.sum | ||
|
|
||
| - name: Backend Testing | ||
| run: | | ||
| cd backend | ||
| go test -v ./... | ||
|
|
||
| - name: Docker Build Test | ||
| run: | | ||
| docker build -t test-backend ./backend | ||
| docker build -t test-frontend ./frontend | ||
|
|
||
| - name: Google Auth | ||
| id: auth | ||
| uses: google-github-actions/auth@v2 | ||
| with: | ||
| workload_identity_provider: 'projects/18499119240/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' | ||
| service_account: 'github-actions-deployer@utba-swarmmap.iam.gserviceaccount.com' | ||
|
|
||
| - name: Set up Cloud SDK | ||
| uses: google-github-actions/setup-gcloud@v2 | ||
|
|
||
| - name: Configure Docker | ||
| run: | | ||
| gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | ||
|
|
||
| - name: Build and Push Frontend | ||
| run: | | ||
| IMAGE_NAME="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/frontend" | ||
| docker build -t "$IMAGE_NAME:${{ github.sha }}" ./frontend | ||
| docker tag "$IMAGE_NAME:${{ github.sha }}" "$IMAGE_NAME:latest" | ||
| docker push "$IMAGE_NAME:${{ github.sha }}" | ||
| docker push "$IMAGE_NAME:latest" | ||
|
|
||
| - name: Deploy Frontend to Cloud Run | ||
| id: deploy-frontend | ||
| uses: google-github-actions/deploy-cloudrun@v2 | ||
| with: | ||
| service: ${{ env.FRONTEND_SERVICE }} | ||
| region: ${{ env.REGION }} | ||
| image: ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/frontend:${{ github.sha }} | ||
| flags: --allow-unauthenticated | ||
|
|
||
| - name: Get Backend URL | ||
| id: backend-url | ||
| run: | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 [actionlint] reported by reviewdog 🐶 |
||
| URL=$(gcloud run services describe ${{ env.SERVICE }} \ | ||
| --platform=managed \ | ||
| --region=${{ env.REGION }} \ | ||
| --format='value(status.url)' 2>/dev/null || echo "") | ||
| if [ -z "$URL" ]; then | ||
| PROJECT_NUMBER=$(gcloud projects describe ${{ env.PROJECT_ID }} --format='value(projectNumber)') | ||
| URL="https://${{ env.SERVICE }}-${PROJECT_NUMBER}.${{ env.REGION }}.run.app" | ||
| fi | ||
| echo "url=$URL" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Build and Push Backend | ||
| run: | | ||
| cp -r frontend/static backend/static | ||
| IMAGE_NAME="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/backend" | ||
| docker build -t "$IMAGE_NAME:${{ github.sha }}" ./backend | ||
| docker tag "$IMAGE_NAME:${{ github.sha }}" "$IMAGE_NAME:latest" | ||
| docker push "$IMAGE_NAME:${{ github.sha }}" | ||
| docker push "$IMAGE_NAME:latest" | ||
|
|
||
| - name: Deploy Backend to Cloud Run | ||
| id: deploy-backend | ||
| uses: google-github-actions/deploy-cloudrun@v2 | ||
| with: | ||
| service: ${{ env.SERVICE }} | ||
| region: ${{ env.REGION }} | ||
| image: ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO }}/backend:${{ github.sha }} | ||
| flags: --allow-unauthenticated | ||
| env_vars: | | ||
| GOOGLE_REDIRECT_URL=${{ steps.backend-url.outputs.url }}/auth/google/callback | ||
| GCP_PROJECT_ID=${{ env.PROJECT_ID }} | ||
| GCS_BUCKET_NAME=${{ env.GCS_BUCKET_NAME }} | ||
| secrets: | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [detect-secrets] reported by reviewdog 🐶
|
||
| GOOGLE_CLIENT_ID=google-oauth-client-id:latest | ||
| GOOGLE_CLIENT_SECRET=google-oauth-client-secret:latest | ||
| MAPBOX_ACCESS_TOKEN=mapbox-access-token:latest | ||
| - name: Health Check | ||
| id: health-check | ||
| run: | | ||
| curl --retry 5 --retry-all-errors --retry-delay 5 -I --fail --silent --show-error "${{ steps.deploy-backend.outputs.url }}" | ||
|
|
||
| - name: Post-Deployment Validation | ||
| id: validation | ||
| env: | ||
| DEPLOYED_URL: ${{ steps.deploy-backend.outputs.url }} | ||
| run: | | ||
| npx playwright install --with-deps chromium | ||
| npx playwright test e2e/validate-deployment.spec.js --config e2e/playwright.config.js | ||
|
|
||
| - name: Handle Deployment Failure | ||
| if: failure() && (steps.validation.outcome == 'failure' || steps.health-check.outcome == 'failure') | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| chmod +x scripts/handle-deployment-failure.sh | ||
| ./scripts/handle-deployment-failure.sh \ | ||
| "${{ env.SERVICE }}" \ | ||
| "${{ env.FRONTEND_SERVICE }}" \ | ||
| "${{ env.REGION }}" \ | ||
| "${{ steps.deploy-backend.outputs.url }}" \ | ||
| "${{ github.sha }}" | ||
|
|
||
| - name: Upload Test Results | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: playwright-report | ||
| path: playwright-report/ | ||
| retention-days: 30 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| # Copyright (c) 2026 Frank Currie (frank@sfle.ca) | ||
| --- | ||
| name: E2E Application Startup Check | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [detect-secrets] reported by reviewdog 🐶