From 3b0bcbe5ca35609f752fd9a8c8b625bc6a65615b Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 6 Sep 2023 14:34:15 -0700 Subject: [PATCH] Update buildpush.yml Add build caching --- .github/workflows/buildpush.yml | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/.github/workflows/buildpush.yml b/.github/workflows/buildpush.yml index 56d0ee3..715ee66 100644 --- a/.github/workflows/buildpush.yml +++ b/.github/workflows/buildpush.yml @@ -27,44 +27,31 @@ jobs: id-token: 'write' steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - # Alternative option - authentication via credentials json - id: 'auth' name: 'Authenticate to GCP' uses: 'google-github-actions/auth@v1' with: credentials_json: '${{ secrets.GCP_CREDENTIALS }}' project_id: $PROJECT_ID - - name: 'Set up gcloud SDK' uses: 'google-github-actions/setup-gcloud@v0' with: version: '442.0.0' - - name: Check gcloud run: | set -x gcloud info - - name: Docker configuration run: |- gcloud auth configure-docker $GCR_URL - - # Build the Docker image + # Build and Push the Docker image - name: Build - run: |- - docker build \ - --tag "$GCR_URL/$PROJECT_ID/$IMAGE:$GITHUB_SHA" \ - --tag "$GCR_URL/$PROJECT_ID/$IMAGE:latest" \ - --build-arg GITHUB_SHA="$GITHUB_SHA" \ - --build-arg GITHUB_REF="$GITHUB_REF" \ - . - # Push the Docker image to Google Artifact Registry - - name: Publish - run: |- - docker push "$GCR_URL/$PROJECT_ID/$IMAGE:latest" \ No newline at end of file + - uses: docker/build-push-action@v2 + with: + context: . + cache-from: type=gha + cache-to: type=gha,mode=max + push: true + tags: "$GCR_URL/$PROJECT_ID/$IMAGE:$GITHUB_SHA,$GCR_URL/$PROJECT_ID/$IMAGE:latest"