Skip to content

Commit 2d6629e

Browse files
committed
ci: ci and deploy in same workflow
1 parent ba28496 commit 2d6629e

2 files changed

Lines changed: 38 additions & 48 deletions

File tree

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,41 @@ jobs:
3131
- name: Test
3232
run: npm test -- --run
3333

34+
deploy:
35+
needs: lint-and-test
36+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v4
42+
43+
- id: 'auth'
44+
uses: 'google-github-actions/auth@v2'
45+
with:
46+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
47+
48+
- name: Set up Google Cloud SDK
49+
uses: google-github-actions/setup-gcloud@v2
50+
with:
51+
project_id: ${{ secrets.GCP_PROJECT_ID }}
52+
53+
- name: Configure Docker for Google Cloud
54+
run: gcloud auth configure-docker
55+
56+
- name: Build Docker image
57+
run: |
58+
docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.CLOUD_RUN_SERVICE }}:${{ github.sha }} .
59+
60+
- name: Push Docker image
61+
run: |
62+
docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.CLOUD_RUN_SERVICE }}:${{ github.sha }}
63+
64+
- name: Deploy to Cloud Run
65+
run: |
66+
gcloud run deploy ${{ secrets.CLOUD_RUN_SERVICE }} \
67+
--image gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.CLOUD_RUN_SERVICE }}:${{ github.sha }} \
68+
--region ${{ secrets.CLOUD_RUN_REGION }} \
69+
--platform managed \
70+
--allow-unauthenticated \
71+
--set-env-vars ANTHROPIC_API_KEY=${{ secrets.ANTHROPIC_API_KEY }}

.github/workflows/deploy.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)