Skip to content

Sync Upstream

Sync Upstream #137

Workflow file for this run

name: Sync Upstream
on:
schedule:
- cron: '0 0 * * *' # 每天凌晨 12 点自动运行
workflow_dispatch: # 也可以手动触发
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout your repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0 # 完整克隆历史
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Add upstream repository
run: git remote add upstream https://github.com/navidrome/navidrome.git
- name: Fetch upstream changes
run: git fetch upstream
- name: Merge upstream changes
run: git merge upstream/master
- name: Push changes to your forked repository
run: |
git push --force https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/TooAndy/navidrome.git master
tag-watcher:
runs-on: ubuntu-latest
needs: [sync]
steps:
- name: Checkout your repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0 # 完整克隆历史
- name: Sync upstream tags
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
LAST_UPSTREAM_TAG=$(git ls-remote --tags https://github.com/navidrome/navidrome.git | cut -d$'\t' -f2 | grep -E '^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$' | cut -d'/' -f3 | sort -V | tail -n 1)
echo "$LAST_UPSTREAM_TAG"
if [ $(git tag | grep $LAST_UPSTREAM_TAG -c) == "0" ]; then
echo "Created new tag: $LAST_UPSTREAM_TAG"
git tag "$LAST_UPSTREAM_TAG"
git push --force --tags https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/TooAndy/navidrome.git
else
echo "find no new tag, exit"
fi