Skip to content

cloud run deployment #568

cloud run deployment

cloud run deployment #568

Workflow file for this run

name: cloud run deployment
on:
workflow_run:
workflows:
- tests
types:
- completed
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
steps:
- name: Checkout repository code
uses: actions/checkout@v3
- name: Inject keys
run: |
echo -en '${{ secrets.KEYS_YAML }}' >> keys.yaml
- name: Authenticate GCP
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Remove tests directory
run: rm -r tests
- name: Build Docker image
run: |
docker build -t jeeves .
- name: Push Docker image to GCP Container Registry
run: |
gcloud auth configure-docker
docker tag jeeves gcr.io/preritdas-api/jeeves
docker push gcr.io/preritdas-api/jeeves
deploy:
runs-on: ubuntu-latest
needs: build
if: ${{ needs.build.result == 'success' }}
steps:
- name: Authenticate GCP
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Deploy to Cloud Run
uses: 'google-github-actions/deploy-cloudrun@v1'
with:
service: 'jeeves'
image: gcr.io/preritdas-api/jeeves
flags: '--min-instances=0 --cpu=2 --memory=4Gi --timeout=5m --allow-unauthenticated --no-cpu-throttling --cpu-boost'
no_traffic: false
- name: Allocate traffic to latest deployment
run: gcloud run services update-traffic --region us-central1 --to-latest jeeves