From ed8e4566b72580a160a08f3a5e7ed1ea32a0eb4e Mon Sep 17 00:00:00 2001 From: SuiShiliang <39945880+SuiShiliang@users.noreply.github.com> Date: Tue, 24 Mar 2026 11:51:50 +0800 Subject: [PATCH 1/2] Add workflow to sync fork with upstream repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 自动同步源仓库 --- .github/workflows/sync-upstream.yml | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/sync-upstream.yml diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml new file mode 100644 index 0000000..6ec21ff --- /dev/null +++ b/.github/workflows/sync-upstream.yml @@ -0,0 +1,36 @@ +name: Sync Fork with Upstream + +on: + # 定时触发:每天 UTC 0 点执行 + schedule: + - cron: '0 0 * * *' + # 手动触发:在 Actions 页面点击按钮运行 + workflow_dispatch: + +jobs: + sync: + runs-on: ubuntu-latest + steps: + # 步骤1:检出当前仓库代码 + - name: Checkout + uses: actions/checkout@v4 + + # 步骤2:配置 Git 用户信息(用于提交记录) + - name: Setup Git + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + + # 步骤3:添加上游仓库地址并拉取更新 + - name: Fetch and Merge Upstream + run: | + # 添加上游远程仓库(如果已存在会报错,但忽略即可) + git remote add upstream https://github.com/Snailclimb/JavaGuide-Interview.git || true + # 拉取上游最新代码 + git fetch upstream + # 切换到你的默认分支(通常是 main 或 master) + git checkout main + # 合并上游分支(使用 merge 策略,保留提交历史) + git merge upstream/main + # 推送到你的 Fork 仓库 + git push origin main From 07a1065cbca0aab127556ff809ce17d92cd16eb1 Mon Sep 17 00:00:00 2001 From: SuiShiliang <39945880+SuiShiliang@users.noreply.github.com> Date: Tue, 24 Mar 2026 15:13:45 +0800 Subject: [PATCH 2/2] Change cron schedule to run every 30 days MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同步频率修改为30天 --- .github/workflows/sync-upstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-upstream.yml b/.github/workflows/sync-upstream.yml index 6ec21ff..f8ab6de 100644 --- a/.github/workflows/sync-upstream.yml +++ b/.github/workflows/sync-upstream.yml @@ -3,7 +3,7 @@ name: Sync Fork with Upstream on: # 定时触发:每天 UTC 0 点执行 schedule: - - cron: '0 0 * * *' + - cron: '0 0 */30 * *' # 手动触发:在 Actions 页面点击按钮运行 workflow_dispatch: