Skip to content

Commit aa39608

Browse files
fix: Refuse to push on pull_request event
Avoid merging pull requests, which is unlikely to be the intended purpose of using this action.
1 parent a653fea commit aa39608

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

entrypoint.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,15 @@ echo "Repository: ${INPUT_REPOSITORY}"
6969
echo "Actor: ${GITHUB_ACTOR}"
7070

7171
if [[ $INPUT_PUSH == 'true' ]]; then
72-
echo "Pushing to branch..."
73-
REMOTE_REPO="https://${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@github.com/${INPUT_REPOSITORY}.git"
74-
git pull "$REMOTE_REPO" "$INPUT_BRANCH"
75-
git push "$REMOTE_REPO" "HEAD:${INPUT_BRANCH}" --tags
72+
if [[ $GITHUB_EVENT_NAME == 'pull_request' ]]; then
73+
echo "Refusing to push on pull_request event since that would merge the pull request." >&2
74+
echo "You probably want to run on push to your default branch instead." >&2
75+
else
76+
echo "Pushing to branch..."
77+
REMOTE_REPO="https://${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@github.com/${INPUT_REPOSITORY}.git"
78+
git pull "$REMOTE_REPO" "$INPUT_BRANCH"
79+
git push "$REMOTE_REPO" "HEAD:${INPUT_BRANCH}" --tags
80+
fi
7681
else
7782
echo "Not pushing"
7883
fi

0 commit comments

Comments
 (0)