From 67988b20e0553712704f5c2bd4b240977ce931e9 Mon Sep 17 00:00:00 2001 From: programminghoch10 <16062290+programminghoch10@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:04:43 +0200 Subject: [PATCH] switch github actions automerge changed variable from env to output --- .github/workflows/automerge.yml | 3 ++- mergehelper.sh | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index fdab4386b..2cc62255a 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -31,6 +31,7 @@ jobs: git fetch other - name: Rebase changes + id: rebase run: | git checkout other/ci-management mergehelper.sh chmod +x mergehelper.sh @@ -44,7 +45,7 @@ jobs: git commit -m "remove workflows" - name: Push result - if: env.CHANGED == 'true' + if: steps.rebase.outputs.changed == 'true' uses: ad-m/github-push-action@v0.8.0 with: force: true diff --git a/mergehelper.sh b/mergehelper.sh index d48d7c35d..c4fe14cab 100644 --- a/mergehelper.sh +++ b/mergehelper.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ -z "$1" ]; then - echo "Usage: $0 " + echo "Usage: $0 " >&2 exit 1 fi @@ -10,7 +10,6 @@ fi # other - lygisk repo MAGISK_CANARY_URL="https://raw.githubusercontent.com/topjohnwu/magisk-files/master/canary.json" -CI_EXTRA_COMMITS=1 BRANCH="$1" @@ -34,7 +33,7 @@ case "$BRANCH" in git checkout origin/master ;; *) - echo "Invalid Branch!" + echo "Invalid Branch!" >&2 exit 1 ;; esac @@ -42,18 +41,23 @@ esac git reset --hard MAGISK_CHANGES_COUNT=$(git log other/ci-build-$BRANCH..HEAD --pretty=%H | wc -l) -LYGISK_CI_LATEST_COMMIT=$(git log -1 other/ci-build-$BRANCH~$CI_EXTRA_COMMITS --pretty=format:"%an %ae %ad %s") -LYGISK_MASTER_LATEST_COMMIT=$(git log -1 other/master --pretty=format:"%an %ae %ad %s") -echo "MAGISK_CHANGES_COUNT=$MAGISK_CHANGES_COUNT" -echo "LYGISK_CI_LATEST_COMMIT=$LYGISK_CI_LATEST_COMMIT" -echo "LYGISK_MASTER_LATEST_COMMIT=$LYGISK_MASTER_LATEST_COMMIT" -if [ $MAGISK_CHANGES_COUNT -eq 0 ] && [ "$LYGISK_CI_LATEST_COMMIT" = "$LYGISK_MASTER_LATEST_COMMIT" ] ; then - echo "CHANGED=false" >> $GITHUB_ENV - echo "No changes detected!" +LYGISK_CURRENT_MASTER_COMMIT=$(git log -1 other/master --pretty=%H) +LYGISK_CI_MASTER_BASE_COMMIT=$(cat ci-master-sha.txt) +echo "MAGISK_CHANGES_COUNT=$MAGISK_CHANGES_COUNT" >&2 +echo "LYGISK_CURRENT_MASTER_COMMIT=$LYGISK_CURRENT_MASTER_COMMIT" >&2 +echo "LYGISK_CI_MASTER_BASE_COMMIT=$LYGISK_CI_MASTER_BASE_COMMIT" >&2 +if [ $MAGISK_CHANGES_COUNT -eq 0 ] && [ "$LYGISK_CURRENT_MASTER_COMMIT" = "$LYGISK_CI_MASTER_BASE_COMMIT" ] ; then + echo "changed=false" >> "$GITHUB_OUTPUT" + echo "No changes detected!" >&2 exit 0 fi -echo "CHANGED=true" >> $GITHUB_ENV +echo "changed=true" >> "$GITHUB_OUTPUT" + +# save the current master commit hash into a file for checking for changes next run +echo "LYGISK_CURRENT_MASTER_COMMIT" > ci-master-sha.txt +git add ci-master-sha.txt +git commit -m "save master base commit sha" if [ $BRANCH = "stable" ] ; then # no need to pick changes on stable