Skip to content

Fix main for deployment #15

Fix main for deployment

Fix main for deployment #15

Workflow file for this run

name: Build and Deploy to Cloud Run
on:
push:
branches:
- main
jobs:
deploy:
# Add 'id-token' with the intended permissions for workload identity federation
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
environment: GCR
env:
PROJECT_ID: ${{secrets.PROJECT_ID}}
GAR_LOCATION: ${{secrets.GAR_LOCATION}} # TODO: update Artifact Registry location
REPOSITORY: ${{secrets.REPOSITORY}} # TODO: update Artifact Registry repository name
SERVICE: image-converter # TODO: update Cloud Run service name
REGION: ${{secrets.GAR_LOCATION}} # TODO: update Cloud Run service region
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
token_format: 'access_token'
# BEGIN - Docker auth and build (NOTE: If you already have a container image, these Docker steps can be omitted)
# Authenticate Docker to Google Cloud Artifact Registry
- name: Docker Auth
run: |-
gcloud auth configure-docker "${{ env.GAR_LOCATION }}-docker.pkg.dev"
- name: Build and Push Container
run: |-
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" ./
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
# END - Docker auth and build
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
# NOTE: If using a pre-built image, update the image name here
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}
# If required, use the Cloud Run url output in later steps
- name: Show Output
run: echo ${{ steps.deploy.outputs.url }}