Skip to content

Commit

Permalink
generate-docker-image-tags supports release triggers (#18)
Browse files Browse the repository at this point in the history
* Updated allowed actions for generate-docker-image-tags

* No PR_NUMBER on release event

* fixed PR_NUMBER strings

* rm accidental double quote

* Update generate-docker-image-tags/action.yml

Co-authored-by: Mikhail Andrenkov <[email protected]>

* Fix quotes

* more quote fmt

* more PR number debugging

* test rm quotes

* backslash

* fix grep pipe usage

Co-authored-by: Mikhail Andrenkov <[email protected]>
  • Loading branch information
michaelvu97 and Mandrenkov authored Nov 14, 2022
1 parent 68fe1d4 commit cf96005
Showing 1 changed file with 11 additions and 8 deletions.
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

0 comments on commit cf96005

Please sign in to comment.