Skip to content

Commit

Permalink
Fix exit code.
Browse files Browse the repository at this point in the history
  • Loading branch information
nwalfield committed Aug 24, 2023
1 parent 5ae43d2 commit 90c41a9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/fast-forward.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ function github_pull_request {
# Triggered by issue ${{ github.event.issue.number }}

# Set to 0 if everything is okay. Set to 1, if fast forwarding is not
# possible or fails.
EXIT_CODE=1
# possible or fails. This is a file to simplify setting this from a
# subshell.
EXIT_CODE=$(mktemp)
echo 1 >$EXIT_CODE

LOG=$(mktemp)
{
Expand Down Expand Up @@ -268,9 +270,10 @@ LOG=$(mktemp)
(
PS4='$ '
set -x
git push origin "$PR_SHA:$BASE_REF" && EXIT_CODE=0
git push origin "$PR_SHA:$BASE_REF"
)
echo '```'
echo 0 >$EXIT_CODE
else
echo -n "Sorry @$(github_event .sender.login),"
echo -n " it is possible to fast forward \`$BASE_REF\` ($BASE_SHA)"
Expand All @@ -285,7 +288,7 @@ LOG=$(mktemp)
echo -n " target repository, you can add a comment with"
echo -n " \`/fast-forward\` to fast forward \`$BASE_REF\` to"
echo " \`$PR_REF\`."
EXIT_CODE=0
echo 0 >$EXIT_CODE
fi
} 2>&1 | tee -a $GITHUB_STEP_SUMMARY "$LOG"

Expand All @@ -307,4 +310,4 @@ else
echo "Can't post a comment: github.event.pull_request.comments_url is not set." | tee -a $GITHUB_STEP_SUMMARY
fi

exit $EXIT_CODE
exit $(cat $EXIT_CODE)

0 comments on commit 90c41a9

Please sign in to comment.