Sync upstream and keep fork workflow

This commit is contained in:
github-actions[bot]
2026-05-25 20:57:31 +00:00
parent e8c9292b77
commit a91f43f602
2 changed files with 64 additions and 1 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ on:
env:
NODE_VERSION: "25"
CRONET_GO_VERSION: "2faf34666c2cc8234f10f2ab6d4c4d6104d34ae2"
CRONET_GO_VERSION: "2fef65f9dba90ddb89a87d00a6eb6165487c10c1"
CRONET_GO_REPO: https://github.com/sagernet/cronet-go.git
BOOTLIN_BASE_URL: https://toolchains.bootlin.com/downloads/releases/toolchains
+63
View File
@@ -0,0 +1,63 @@
name: Sync upstream
on:
schedule:
# 每天北京时间 04:00 同步(UTC 20:00
- cron: '0 20 * * *'
workflow_dispatch:
permissions:
contents: write
concurrency:
group: sync-upstream
cancel-in-progress: false
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout fork
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Add upstream remote
run: |
git remote add upstream https://github.com/alireza0/s-ui.git
git fetch upstream main
- name: Sync main from upstream
run: |
set -euo pipefail
# Preserve fork workflows. GITHUB_TOKEN cannot push commits that
# create/update workflow files from upstream (for example docker.yml).
tmp_workflows="$(mktemp -d)"
if [ -d .github/workflows ]; then
cp -a .github/workflows/. "$tmp_workflows/"
fi
# Make the fork match upstream exactly, avoiding merge/rebase conflicts
# from divergent local history.
git checkout main
git reset --hard upstream/main
rm -rf .github/workflows
mkdir -p .github/workflows
cp -a "$tmp_workflows/." .github/workflows/
git add .github/workflows
if git diff --cached --quiet; then
echo "Fork is already in sync with upstream."
exit 0
fi
git commit -m "Sync upstream and keep fork workflow"
git push --force-with-lease origin main