-
-
Notifications
You must be signed in to change notification settings - Fork 667
100 lines (86 loc) · 2.77 KB
/
Copy pathapi.yml
File metadata and controls
100 lines (86 loc) · 2.77 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
name: api
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
id-token: write
jobs:
test:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: stable
- name: Generate Firebase credentials
run: |
bash tests/generate-firebase-credentials.sh tests/firebase-credentials.json
echo "FIREBASE_CREDENTIALS=$(jq -c . tests/firebase-credentials.json)" >> $GITHUB_ENV
- name: Start Services
working-directory: ./tests
run: docker compose up -d --build
- name: Wait for services to be healthy
working-directory: ./tests
run: |
echo "Waiting for API to be healthy..."
for i in $(seq 1 40); do
if docker compose exec api curl -sf http://localhost:8000/health >/dev/null 2>&1; then
echo "API is healthy!"
break
fi
if [ $i -eq 40 ]; then
echo "API failed to become healthy"
docker compose logs api
exit 1
fi
echo "Attempt $i/40 - waiting 5s..."
sleep 5
done
- name: Seed Database
working-directory: ./tests
run: |
echo "Waiting for seed container to finish..."
docker compose wait seed || true
sleep 2
- name: Run Integration Tests
working-directory: ./tests
run: go test -v -timeout 300s ./...
- name: Collect Logs on Failure
if: failure()
working-directory: ./tests
run: |
docker compose logs --tail 200
- name: Stop Services
if: always()
working-directory: ./tests
run: docker compose down -v
deploy:
name: Deploy 🚀
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v3
- name: Trigger Cloud Build Deploy
run: |
BUILD_ID=$(gcloud builds triggers run api-httpsms-com \
--region=global \
--project=httpsms-86c51 \
--sha=${{ github.sha }} \
--format="value(metadata.build.id)")
echo "Build ID: $BUILD_ID"
echo "View build logs: https://console.cloud.google.com/cloud-build/builds/$BUILD_ID?project=httpsms-86c51"