github-merge-pr: Add option for no remote operations
authorHauke Mehrtens <hauke@hauke-m.de>
Sat, 6 Jul 2024 16:07:23 +0000 (18:07 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Tue, 16 Jul 2024 17:09:37 +0000 (19:09 +0200)
This adds the new option GITHUB_NO_PUSH which will prevent the script
from doing any changes to remote repositories.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
github-merge-pr.sh

index db49c92860e1f189f4e305118d1aafd0ed423a0a..76aec20b73d941aa69c9803d1d0d5236ce51a70f 100755 (executable)
@@ -158,6 +158,21 @@ if [ "$(echo "$PR_INFO" | jq -r ".maintainer_can_modify")" == "true" ]; then
                exit 9
        fi
 
+       if [ "$GITHUB_NO_PUSH" = "1" ]; then
+               echo "next commands:"
+               if [ "$(echo "$PR_INFO" | jq -r ".maintainer_can_modify")" == "true" ]; then
+                       echo "$GIT push $PR_USER HEAD:$PR_BRANCH --force"
+                       echo "$GIT checkout $BRANCH"
+                       echo "$GIT merge --ff-only $PR_USER/$PR_BRANCH"
+               else
+                       echo "$GIT checkout $BRANCH"
+                       echo "$GIT merge --ff-only $LOCAL_PR_BRANCH"
+               fi
+               echo "$GIT push"
+               echo "$GIT branch -D $LOCAL_PR_BRANCH"
+               exit 20
+       fi
+
        echo "Force pushing $LOCAL_PR_BRANCH to HEAD:$PR_BRANCH for $PR_USER"
        if ! $GIT push $PR_USER HEAD:$PR_BRANCH --force; then
                echo "Failed to force push HEAD to $PR_USER" >&2