Skip to content

Fix docker version #646

Fix docker version

Fix docker version #646

Workflow file for this run

name: Artifact Registry
on:
push:
branches:
- main
pull_request:
release:
types: [published]
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pages: write
id-token: write
attestations: write
jobs:
build-and-push:
runs-on: ubuntu-latest
env:
ARTIFACT_REPO: public
IMAGE_NAME: eds
PLATFORM_PROJECT_ID: shopmonkey-v2
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
timeout-minutes: 2
with:
registry: us-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCP_SA_KEY }}
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v8
- name: Construct the tags
id: construct_tags
run: |
# default to the SHA
TAGS=${{ github.sha }}
# if we're on the main branch, add the beta tag
if [[ $GITHUB_REF == 'refs/heads/main' ]]; then
TAGS="$TAGS beta"
fi
# if it's a release, use the version and latest tags
if [[ $GITHUB_EVENT_NAME == 'release' ]]; then
VERSION_TAG=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
TAGS="$TAGS $VERSION_TAG latest"
fi
for TAG in $TAGS; do
TAG_LIST+="us-docker.pkg.dev/${{ env.PLATFORM_PROJECT_ID }}/${{ env.ARTIFACT_REPO }}/${{ env.IMAGE_NAME }}:$TAG,"
done
# remove the trailing comma
TAG_LIST=${TAG_LIST%,}
echo tags=$TAG_LIST >> $GITHUB_OUTPUT
- name: Build and push to Artifact Registry
uses: docker/build-push-action@v6
id: push
with:
push: true
context: .
file: ./Dockerfile
tags: ${{ steps.construct_tags.outputs.tags }}
build-args: |
BUILD_DATE=${{ steps.date.outputs.date }}
GIT_BRANCH=${{ steps.branch-name.outputs.current_branch }}
GIT_SHA=${{ github.sha }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: us-docker.pkg.dev/${{ env.PLATFORM_PROJECT_ID }}/${{ env.ARTIFACT_REPO }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true