Skip to content

Commit

Permalink
Update buildpush.yml
Browse files Browse the repository at this point in the history
Add build caching
  • Loading branch information
argonaut0 committed Sep 6, 2023
1 parent 3bc0d8f commit 3b0bcbe
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions .github/workflows/buildpush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
- 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"

0 comments on commit 3b0bcbe

Please sign in to comment.