Sync with upstream #5
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
name: Sync with upstream | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Add upstream remote | |
run: | | |
git remote add upstream https://github.com/vernesong/OpenClash.git | |
git fetch upstream | |
- name: Sync with upstream (excluding specific files) | |
run: | | |
git checkout main | |
git merge upstream/dev --no-commit --no-ff | |
git reset HEAD $(cat .syncignore) | |
git checkout -- $(cat .syncignore) | |
git status | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git commit -m "Sync dengan upstream dev branch (kecuali file yang dikecualikan)" || echo "No changes to commit" | |
git push origin main || echo "No changes to push" | |
- name: Update version | |
run: | | |
UPSTREAM_VERSION=$(git rev-parse upstream/dev) | |
COMMIT_DATE=$(git log -1 --format=%cd --date=short upstream/dev) | |
sed -i "s/versi: .*/versi: dev-$COMMIT_DATE (${UPSTREAM_VERSION:0:7})/" README.md | |
git add README.md | |
git commit -m "Update versi ke dev-$COMMIT_DATE (${UPSTREAM_VERSION:0:7})" || echo "No version changes to commit" | |
git push origin main || echo "No version changes to push" |