use GAR instead GCR #68
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
on: | |
push: | |
branches: | |
- develop | |
name: Build and Deploy to Cloud Run on merge to branch 'develop' | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID_DEV }} | |
REGION: ${{ secrets.GCP_REGION_DEV }} | |
SERVICE_NAME: ${{ secrets.SERVICE_NAME_DEV }} | |
REPOSITORY_NAME: ${{ secrets.REPOSITORY_NAME_DEV }} | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER_DEV }} | |
service_account: github-actions@${{ secrets.GCP_PROJECT_ID_DEV }}.iam.gserviceaccount.com | |
- name: Authorize Docker push | |
run: gcloud auth configure-docker artifactregistry | |
- name: Build Docker image | |
run: docker build -t $REGION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$SERVICE_NAME:${{ github.sha }} . | |
- name: Push Docker Image | |
run: docker push $REGION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$SERVICE_NAME:${{ github.sha }} | |
- name: Deploy to Cloud Run | |
run: |- | |
gcloud run deploy $SERVICE_NAME \ | |
--project=$PROJECT_ID \ | |
--image=$REGION-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$SERVICE_NAME:${{ github.sha }} \ | |
--region=$REGION \ | |
--allow-unauthenticated |