Skip to content

Commit

Permalink
switch github actions automerge changed variable from env to output
Browse files Browse the repository at this point in the history
  • Loading branch information
programminghoch10 committed Oct 16, 2024
1 parent 4c2a1e9 commit 67988b2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/[email protected]
with:
force: true
Expand Down
28 changes: 16 additions & 12 deletions mergehelper.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ -z "$1" ]; then
echo "Usage: $0 <branch>"
echo "Usage: $0 <branch>" >&2
exit 1
fi

Expand All @@ -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"

Expand All @@ -34,26 +33,31 @@ case "$BRANCH" in
git checkout origin/master
;;
*)
echo "Invalid Branch!"
echo "Invalid Branch!" >&2
exit 1
;;
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
Expand Down

0 comments on commit 67988b2

Please sign in to comment.