Skip to content

generate-docker-image-tags supports release triggers #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 14, 2022
19 changes: 11 additions & 8 deletions generate-docker-image-tags/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ runs:
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]
then
BRANCH=$GITHUB_HEAD_REF
elif [ "$GITHUB_EVENT_NAME" == "push" ]
elif [ "$GITHUB_EVENT_NAME" == "push" ] || [ "$GITHUB_EVENT_NAME" == "release" ]
then
BRANCH=${GITHUB_REF##*/}
else
printf 'Cannot determine tags: Workflow must be triggered by "push" or "pull_request" event.' && exit 1
printf 'Cannot determine tags: Workflow must be triggered by "push", "pull_request", or "release" event.' && exit 1
fi

printf "::set-output name=branch::$BRANCH"
Expand All @@ -62,14 +62,17 @@ runs:

if [ "$GITHUB_EVENT_NAME" == "pull_request" ]
then
PR_NUMBER=${{ github.event.number }}
else
PR_NUMBER="${{ github.event.number }}"
elif [ "$GITHUB_EVENT_NAME" == "push" ]
then
# Workflow was triggered by a "push" event.
PR_NUMBER=$(
echo "${{ github.event.head_commit.message }}" \
| grep -o "(#[0-9]*)" \
| sed 's/[#()]//g'
PR_NUMBER=$( \
(echo "${{ github.event.head_commit.message }}" \
| grep -o "\(#[0-9]\+\)" || true) \
| sed "s/[#()]//g" \
)
else
PR_NUMBER=""
fi

# Add additional tags for each Story ID associated with this PR.
Expand Down