Skip to content

Commit

Permalink
Fix ref-id output of build-docker
Browse files Browse the repository at this point in the history
Signed-off-by: cosa65 <[email protected]>
  • Loading branch information
cosa65 committed Aug 18, 2023
1 parent b3849b7 commit f53d0d9
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,19 @@ jobs:
- id: ref
name: Format docker tag and repository name for current image.
run: |-
# This will take a ref like `refs/heads/master`
# and turn it into `refs-heads-master`
REF_ID=$(echo $GITHUB_REF | sed 's/\//-/g')
if [ "${{ github.event_name }}" = "pull_request_target" ]; then
# Construct the PR_GITHUB_REF for our pull request copying GITHUB_REF's format
# We can't use GITHUB_REF because it is set to master in this event
# More info: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
PR_GITHUB_REF="refs/pull/${{ github.event.pull_request.number }}/merge"
REF_ID=$(echo $PR_GITHUB_REF | sed 's/\//-/g')
else
# This will take a ref like `refs/heads/master`
# and turn it into `refs-heads-master`
REF_ID=$(echo $GITHUB_REF | sed 's/\//-/g')
fi
echo "ref-id=$REF_ID" >> $GITHUB_OUTPUT
# the final tag is something like:
Expand All @@ -131,16 +141,9 @@ jobs:
BATCH_IMAGE_TAG=production
elif [ "${{ github.event_name }}" = "pull_request_target" ]; then
COMMIT_SHA="${{ github.sha }}"
# Construct the REF_ID for our pull request in the same format
# We can't use GITHUB_REF because it is set to master
# More info: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
PR_GITHUB_REF="refs/pull/${{ github.event.pull_request.number }}/merge"
PR_REF_ID=$(echo $PR_GITHUB_REF | sed 's/\//-/g')
IMAGE_TAG="$PR_REF_ID-$COMMIT_SHA"
IMAGE_TAG="$REF_ID-$COMMIT_SHA"
TIMESTAMP=$TIMESTAMP
BATCH_IMAGE_TAG=$PR_REF_ID
BATCH_IMAGE_TAG=$REF_ID
else
COMMIT_SHA=$GITHUB_SHA
IMAGE_TAG="$REF_ID-$COMMIT_SHA"
Expand Down

0 comments on commit f53d0d9

Please sign in to comment.