Update aws-sdk-go-v2 monorepo #728
Workflow file for this run
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: 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 | |
env: | |
GIT_BRANCH: ${{ steps.branch-name.outputs.current_branch }} | |
PR_SHA: ${{ github.event.pull_request.head.sha }} | |
MERGE_SHA: ${{ github.sha }} | |
run: | | |
SHA="" | |
if [ "$GIT_BRANCH" = "main" ]; | |
then | |
SHA=$MERGE_SHA | |
else | |
SHA=$PR_SHA | |
fi | |
echo sha=$SHA >> $GITHUB_OUTPUT | |
# default to the SHA | |
TAGS="$SHA" | |
VERSION="$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=$(echo $GITHUB_REF | sed 's/refs\/tags\///') | |
TAGS="$TAGS $VERSION latest" | |
fi | |
echo version=$VERSION >> $GITHUB_OUTPUT | |
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=${{ steps.construct_tags.outputs.sha }} | |
VERSION=${{ steps.construct_tags.outputs.version }} | |
- 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 |