.github/workflows/sync_upstream.yml #53
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
workflow_call: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 16 * * *" | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.WF_TOKEN }} | |
- name: sync | |
id: sync | |
shell: bash | |
run: | | |
git config --global user.name 'j-hc' | |
git config --global user.email 'j-hc@users.noreply.github.com' | |
if [[ $(git log | grep Author | head -1) == *"semantic"* ]]; then | |
git reset --hard HEAD~1 | |
fi | |
T=$(git tag -l) | |
git remote add upstream https://github.com/revanced/revanced-cli | |
git tag -d $T | |
git fetch upstream --tags -f | |
C=$(git rev-list --left-right --count origin/main...remotes/upstream/main | awk '{print$2}') | |
echo "ahead $C commits" | |
if [ "$C" -gt 0 ]; then | |
echo "rebasing" | |
git push origin -d $T | |
if ! git rebase -X ours upstream/main; then | |
git diff --name-only --diff-filter=U | xargs git rm | |
GIT_EDITOR=true git rebase --continue | |
fi | |
git push --tags -f | |
git push -f | |
else | |
echo "in sync" | |
fi | |