Skip to content

Commit

Permalink
build: add github action for deploy to GCP
Browse files Browse the repository at this point in the history
  • Loading branch information
Will413028 committed Feb 24, 2024
1 parent 143dd82 commit 29e140e
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI/CD

on:
push:
branches: [main]
pull_request:
branches: [main]

workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest

permissions:
contents: "read"
id-token: "write"

env:
IMAGE_NAME: gcr.io/${{secrets.PROJECT_ID}}/ai-recipe-generator

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
workload_identity_provider: ${{secrets.WORKLOAD_IDENTITY_PROVIDER_LOCATION}}
service_account: ${{secrets.SERVICE_ACCOUNT}}

- name: Configure Docker
run: gcloud auth configure-docker --quiet

- name: Build Docker image
run: docker build . -t $IMAGE_NAME --cache-from $IMAGE_NAME

- name: Push Docker image
run: docker push $IMAGE_NAME

- id: deploy
name: Deploy Docker image
uses: "google-github-actions/deploy-cloudrun@v2"
with:
image: ${{ env.IMAGE_NAME }}
region: asia-east1
service: ai-recipe-generator
flags: --port=8501

- name: Test URL
run: curl "${{ steps.deploy.outputs.url }}"

0 comments on commit 29e140e

Please sign in to comment.