Update deployment script #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Deploy to Google Cloud | |
on: | |
push: | |
branches: | |
- feature-deploy | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Google Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
export_default_credentials: true | |
- name: Authenticate to Google Cloud | |
run: gcloud auth activate-service-account --key-file=${{ secrets.GCP_SA_KEY }} | |
env: | |
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GCP_SA_KEY }} | |
- name: Configure Docker for Google Artifact Registry | |
working-directory: ./backend | |
run: | | |
gcloud auth configure-docker europe-west3-docker.pkg.dev | |
- name: Build Docker image | |
working-directory: ./backend | |
run: | | |
docker buildx build --platform linux/amd64 -t europe-west3-docker.pkg.dev/thf-climate-cloud/thf-climate/thf-climate:latest . | |
- name: Push Docker image to Artifact Registry | |
working-directory: ./backend | |
run: | | |
docker push europe-west3-docker.pkg.dev/thf-climate-cloud/thf-climate/thf-climate:latest | |
- name: Deploy to Cloud Run | |
working-directory: ./backend | |
run: | | |
gcloud run deploy thf-climate-run \ | |
--image=europe-west3-docker.pkg.dev/thf-climate-cloud/thf-climate/thf-climate:latest \ | |
--port=8000 \ | |
--region=europe-west3 \ | |
--allow-unauthenticated \ | |
--min-instances=1 \ | |
--max-instances=5 |