Skip to content

Update

Update #19

Workflow file for this run

name: 'Build and Deploy to Cloud Run'
on:
push:
branches:
- 'main'
env:
PROJECT_ID: '${{ secrets.PROJECT_ID }}'
GCR_REGION: '${{ secrets.GCR_REGION }}'
GCR_SERVICE: '${{ secrets.GCR_SERVICE }}'
GAR_NAME: '${{ secrets.GAR_NAME }}'
GAR_REGION: '${{ secrets.GAR_REGION }}'
jobs:
deploy:
runs-on: 'ubuntu-latest'
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: 'Checkout'
uses: 'actions/checkout@v4'
- name: 'Authenticate to GCP'
id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_CREDS }}'
- name: Set up Cloud SDK
uses: 'google-github-actions/setup-gcloud@v2'
- name: 'Docker Auth To GAR'
run: |
gcloud auth configure-docker "${{env.GAR_REGION}}-docker.pkg.dev"
- name: 'Build and Push To GAR'
run: |-
DOCKER_TAG="gcr.io/${{ env.PROJECT_ID }}/gcp-automation:latest"
docker build --tag "${DOCKER_TAG}" .
docker push "${DOCKER_TAG}"
- name: Deploy to Cloud Run
run: |
echo SERVICE_NAME ${{ env.GCR_SERVICE }}
gcloud run deploy ${{ env.GCR_SERVICE }} \
--image ${{ env.GAR_REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.GAR_NAME }}/${{ env.GCR_SERVICE }}:${{ github.sha }} \
--platform managed \
--region ${{ env.GCR_REGION }} \
--port 5757 \
--allow-unauthenticated
- name: 'Show output'
run: |2-
echo ${{ steps.deploy.outputs.url }}