Skip to content

Commit

Permalink
Derive PR numbers correctly on push events (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandrenkov authored Oct 7, 2022
2 parents 60eedcd + c6ad5d4 commit 7923e15
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions generate-docker-image-tags/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,21 @@ runs:
TAGS="${{ inputs.prefix }}.$BRANCH,${{ inputs.prefix }}.$COMMIT_SHA"
fi
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]
then
PR_NUMBER=${{ github.event.number }}
else
# Workflow was triggered by a "push" event.
PR_NUMBER=$(
echo "${{ github.event.head_commit.message }}" \
| grep -o "(#[0-9]*)" \
| sed 's/[#()]//g'
)
fi
# Add additional tags for each Story ID associated with this PR.
if [ ! -z "${{ inputs.shortcut-api-token }}" ]; then
url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/pull/${{ github.event.number }}"
if [ ! -z "$PR_NUMBER" ] && [ ! -z "${{ inputs.shortcut-api-token }}" ]; then
url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/pull/$PR_NUMBER"
ids=$(
curl --silent -X GET \
Expand All @@ -74,7 +86,9 @@ runs:
)
while read -r id; do
TAGS="$TAGS,sc-$id"
if [ ! -z "$id" ]; then
TAGS="$TAGS,sc-$id"
fi
done <<< "$ids"
fi
Expand Down

0 comments on commit 7923e15

Please sign in to comment.