Remove the mandatory gcp_project
config option and leave it up to t…
#15
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: Build and Push Docker image | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
packages: 'write' | |
id-token: 'write' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image to Github Container Registry | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ghcr.io/etvt/aitestdrive:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Login to Google Cloud | |
id: 'google-cloud-auth' | |
if: github.event_name != 'pull_request' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
workload_identity_provider: '${{ secrets.GC_WIF_PROVIDER }}' | |
service_account: '${{ secrets.GC_WIF_SERVICE_ACCOUNT }}' | |
- name: Set up Cloud SDK | |
uses: 'google-github-actions/setup-gcloud@v1' | |
with: | |
project_id: '${{ secrets.GC_PROJECT_ID }}' | |
- name: Login to Google Container Registry | |
run: |- | |
gcloud auth configure-docker gcr.io | |
- name: Build and push Docker image to Google Container Registry | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: gcr.io/${{ secrets.GC_PROJECT_ID }}/aitestdrive:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |