From c59464a076f18280a21ad4f4a96bd375dc4e50f3 Mon Sep 17 00:00:00 2001 From: pooneyy <85266337+pooneyy@users.noreply.github.com> Date: Sat, 28 Feb 2026 13:20:58 +0800 Subject: [PATCH 1/5] ci(sync): update sync workflow remote configuration - add explicit `ssh-host` field to remote matrix entries for clarity - update ssh-keyscan commands to use `ssh-host` instead of `name` - rename remote identifiers in matrix from domain names to platform names --- .github/workflows/sync.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 14a008e4b..ded15f95c 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -23,10 +23,12 @@ jobs: fail-fast: false matrix: remote: - - name: codeberg.org + - name: Codeberg + ssh-host: codeberg.org ssh-url: git@codeberg.org:pooneyy/1Panel-Appstore.git https-url: https://codeberg.org/pooneyy/1Panel-Appstore - - name: gitea.com + - name: Gitea + ssh-host: gitea.com ssh-url: git@gitea.com:pooneyy/1Panel-Appstore.git https-url: https://gitea.com/pooneyy/1Panel-Appstore @@ -49,7 +51,7 @@ jobs: - name: 添加目标主机的公钥 run: | mkdir -p ~/.ssh - ssh-keyscan ${{ matrix.remote.name }} >> ~/.ssh/known_hosts + ssh-keyscan ${{ matrix.remote.ssh-host }} >> ~/.ssh/known_hosts - name: 配置本地仓库 run: | From f2c11a2a5bc6ed27ea139536fe506dee0662ca96 Mon Sep 17 00:00:00 2001 From: pooneyy <85266337+pooneyy@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:18:46 +0800 Subject: [PATCH 2/5] ci(sync): add SSH port configuration support - rename sync job to ssh-sync for clarity - add SSH_PORT variable support for ssh-keyscan command - implement conditional logic for SSH port configuration - update known_hosts setting to support non-standard SSH ports --- .github/workflows/sync.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index ded15f95c..c06b5fafd 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -16,7 +16,7 @@ permissions: contents: read jobs: - sync: + ssh-sync: name: 同步到 ${{ matrix.remote.name }} runs-on: ubuntu-latest strategy: @@ -51,7 +51,13 @@ jobs: - name: 添加目标主机的公钥 run: | mkdir -p ~/.ssh - ssh-keyscan ${{ matrix.remote.ssh-host }} >> ~/.ssh/known_hosts + SSH_HOST=${{ matrix.remote.ssh-host }} + SSH_PORT=${{ matrix.remote.ssh-port }} + if [ -n "$SSH_PORT" ]; then + ssh-keyscan -p $SSH_PORT $SSH_HOST >> ~/.ssh/known_hosts + else + ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts + fi - name: 配置本地仓库 run: | From bf66ce95917bf43c948a1fb4ae27db40d128c39d Mon Sep 17 00:00:00 2001 From: pooneyy <85266337+pooneyy@users.noreply.github.com> Date: Mon, 2 Mar 2026 11:50:07 +0800 Subject: [PATCH 3/5] ci(sync): add HTTP sync workflow - add new `http-sync` job for syncing to remote repositories via HTTPS - configure git user and authentication using PAT secrets - implement branch detection and tracking for all remote branches - add force push with pruning for all branches and tags - include success/failure summary logging for workflow runs --- .github/workflows/sync.yml | 61 +++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index c06b5fafd..f55997468 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -88,4 +88,63 @@ jobs: - name: 记录失败摘要 if: failure() run: | - echo "❌ $(date +"%Y-%m-%d %H:%M:%S %:z") 未能同步到 **${{ matrix.remote.https-url }}**" >> $GITHUB_STEP_SUMMARY \ No newline at end of file + echo "❌ $(date +"%Y-%m-%d %H:%M:%S %:z") 未能同步到 **${{ matrix.remote.https-url }}**" >> $GITHUB_STEP_SUMMARY + + http-sync: + name: 同步到 ${{ matrix.remote.name }} + if: false # 禁用 + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + remote: + - name: + https-url: + pat-secret: + + steps: + - name: 检出完整仓库 + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: 检测默认分支 + run: | + echo "默认分支: ${{ github.event.repository.default_branch }}" + echo "当前分支 (pushed): ${{ github.ref_name }}" + + - name: 配置本地仓库 + run: | + git config --global --add safe.directory ${{ github.workspace }} + git config user.name "github-actions[bot]" + git config user.email ${{ secrets.SYNC_EMAIL }} + BASE_PATH="${{ matrix.remote.https-url }}" + BASE_PATH="${BASE_PATH#https://}" + if [[ ! "$BASE_PATH" =~ \.git$ ]]; then + BASE_PATH="${BASE_PATH}.git" + fi + git remote add ${{ matrix.remote.name }} "https://git:${{ secrets[matrix.remote.pat-secret] }}@${BASE_PATH}" + git branch -r | grep -v '\->' | while read remote; do + branch=${remote#origin/} + git branch --track "$branch" "$remote" 2>/dev/null && echo "创建本地分支: $branch" || echo "分支 $branch 已存在" + done + + - name: 列出所有本地分支 + run: git branch + + - name: 强制推送所有分支和所有标签到 ${{ matrix.remote.name }} + run: | + echo "将所有分支推送到 ${{ matrix.remote.name }} (修剪模式)..." + git push --force --prune ${{ matrix.remote.name }} --all + echo "将所有 tags 推送到 ${{ matrix.remote.name }}..." + git push --force ${{ matrix.remote.name }} --tags + + - name: 记录成功摘要 + if: success() + run: | + echo "✅ $(date +"%Y-%m-%d %H:%M:%S %:z") 成功同步到 **${{ matrix.remote.https-url }}**" >> $GITHUB_STEP_SUMMARY + + - name: 记录失败摘要 + if: failure() + run: | + echo "❌ $(date +"%Y-%m-%d %H:%M:%S %:z") 未能同步到 **${{ matrix.remote.https-url }}**" >> $GITHUB_STEP_SUMMARY From d33b4ffee80e411a81082104cb989d85d662c52a Mon Sep 17 00:00:00 2001 From: pooneyy <85266337+pooneyy@users.noreply.github.com> Date: Tue, 3 Mar 2026 00:03:17 +0800 Subject: [PATCH 4/5] ci(sync): optimize synchronization workflow using mirror push - replace separate branch and tag pushes with single `git push --mirror` command - update echo messages to reflect simplified synchronization process --- .github/workflows/sync.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index f55997468..9a2adf73d 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -75,10 +75,8 @@ jobs: - name: 强制推送所有分支和所有标签到 ${{ matrix.remote.name }} run: | - echo "将所有分支推送到 ${{ matrix.remote.name }} (修剪模式)..." - git push --force --prune ${{ matrix.remote.name }} --all - echo "将所有 tags 推送到 ${{ matrix.remote.name }}..." - git push --force ${{ matrix.remote.name }} --tags + echo "将仓库同步到 ${{ matrix.remote.name }}..." + git push --mirror ${{ matrix.remote.name }} - name: 记录成功摘要 if: success() @@ -134,10 +132,8 @@ jobs: - name: 强制推送所有分支和所有标签到 ${{ matrix.remote.name }} run: | - echo "将所有分支推送到 ${{ matrix.remote.name }} (修剪模式)..." - git push --force --prune ${{ matrix.remote.name }} --all - echo "将所有 tags 推送到 ${{ matrix.remote.name }}..." - git push --force ${{ matrix.remote.name }} --tags + echo "将仓库同步到 ${{ matrix.remote.name }}..." + git push --mirror ${{ matrix.remote.name }} - name: 记录成功摘要 if: success() From 086d09f1210a1a17d37d2b4ec6dc44f8aef038aa Mon Sep 17 00:00:00 2001 From: pooneyy <85266337+pooneyy@users.noreply.github.com> Date: Tue, 3 Mar 2026 01:00:51 +0800 Subject: [PATCH 5/5] ci(sync): rename and add scheduled sync workflow - rename existing sync.yml to sync-auto.yml for clarity - add new sync-schedule.yml workflow for automated hourly synchronization - configure SSH-based mirroring to remote repository with fail-fast strategy - include success/failure summary reporting for each sync job - disable HTTP sync job by default for future use --- .github/workflows/{sync.yml => sync-auto.yml} | 0 .github/workflows/sync-schedule.yml | 135 ++++++++++++++++++ 2 files changed, 135 insertions(+) rename .github/workflows/{sync.yml => sync-auto.yml} (100%) create mode 100644 .github/workflows/sync-schedule.yml diff --git a/.github/workflows/sync.yml b/.github/workflows/sync-auto.yml similarity index 100% rename from .github/workflows/sync.yml rename to .github/workflows/sync-auto.yml diff --git a/.github/workflows/sync-schedule.yml b/.github/workflows/sync-schedule.yml new file mode 100644 index 000000000..c5233a4ed --- /dev/null +++ b/.github/workflows/sync-schedule.yml @@ -0,0 +1,135 @@ +name: 同步仓库到其它远程仓库(定时任务) + +on: + schedule: + - cron: 0 */1 * * * + +permissions: + contents: read + +jobs: + ssh-sync: + name: 同步到 ${{ matrix.remote.name }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + remote: + - name: Smartscf + ssh-host: repo.smartscf.cn + ssh-port: 8122 + ssh-url: ssh://git@repo.smartscf.cn:8122/pooneyy/1Panel-Appstore.git + https-url: https://repo.smartscf.cn/pooneyy/1Panel-Appstore + + steps: + - name: 检出完整仓库 + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: 检测默认分支 + run: | + echo "默认分支: ${{ github.event.repository.default_branch }}" + echo "当前分支 (pushed): ${{ github.ref_name }}" + + - name: 配置 SSH agent 并加载私钥 + uses: webfactory/ssh-agent@v0.9.1 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: 添加目标主机的公钥 + run: | + mkdir -p ~/.ssh + SSH_HOST=${{ matrix.remote.ssh-host }} + SSH_PORT=${{ matrix.remote.ssh-port }} + if [ -n "$SSH_PORT" ]; then + ssh-keyscan -p $SSH_PORT $SSH_HOST >> ~/.ssh/known_hosts + else + ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts + fi + + - name: 配置本地仓库 + run: | + git config --global --add safe.directory ${{ github.workspace }} + git config user.name "github-actions[bot]" + git config user.email ${{ secrets.SYNC_EMAIL }} + git remote add ${{ matrix.remote.name }} ${{ matrix.remote.ssh-url }} + git branch -r | grep -v '\->' | while read remote; do + branch=${remote#origin/} + git branch --track "$branch" "$remote" 2>/dev/null && echo "创建本地分支: $branch" || echo "分支 $branch 已存在" + done + + - name: 列出所有本地分支 + run: git branch + + - name: 强制推送所有分支和所有标签到 ${{ matrix.remote.name }} + run: | + echo "将仓库同步到 ${{ matrix.remote.name }}..." + git push --mirror ${{ matrix.remote.name }} + + - name: 记录成功摘要 + if: success() + run: | + echo "✅ $(date +"%Y-%m-%d %H:%M:%S %:z") 成功同步到 **${{ matrix.remote.https-url }}**" >> $GITHUB_STEP_SUMMARY + + - name: 记录失败摘要 + if: failure() + run: | + echo "❌ $(date +"%Y-%m-%d %H:%M:%S %:z") 未能同步到 **${{ matrix.remote.https-url }}**" >> $GITHUB_STEP_SUMMARY + + http-sync: + name: 同步到 ${{ matrix.remote.name }} + if: false # 禁用 + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + remote: + - name: + https-url: + pat-secret: + + steps: + - name: 检出完整仓库 + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: 检测默认分支 + run: | + echo "默认分支: ${{ github.event.repository.default_branch }}" + echo "当前分支 (pushed): ${{ github.ref_name }}" + + - name: 配置本地仓库 + run: | + git config --global --add safe.directory ${{ github.workspace }} + git config user.name "github-actions[bot]" + git config user.email ${{ secrets.SYNC_EMAIL }} + BASE_PATH="${{ matrix.remote.https-url }}" + BASE_PATH="${BASE_PATH#https://}" + if [[ ! "$BASE_PATH" =~ \.git$ ]]; then + BASE_PATH="${BASE_PATH}.git" + fi + git remote add ${{ matrix.remote.name }} "https://git:${{ secrets[matrix.remote.pat-secret] }}@${BASE_PATH}" + git branch -r | grep -v '\->' | while read remote; do + branch=${remote#origin/} + git branch --track "$branch" "$remote" 2>/dev/null && echo "创建本地分支: $branch" || echo "分支 $branch 已存在" + done + + - name: 列出所有本地分支 + run: git branch + + - name: 强制推送所有分支和所有标签到 ${{ matrix.remote.name }} + run: | + echo "将仓库同步到 ${{ matrix.remote.name }}..." + git push --mirror ${{ matrix.remote.name }} + + - name: 记录成功摘要 + if: success() + run: | + echo "✅ $(date +"%Y-%m-%d %H:%M:%S %:z") 成功同步到 **${{ matrix.remote.https-url }}**" >> $GITHUB_STEP_SUMMARY + + - name: 记录失败摘要 + if: failure() + run: | + echo "❌ $(date +"%Y-%m-%d %H:%M:%S %:z") 未能同步到 **${{ matrix.remote.https-url }}**" >> $GITHUB_STEP_SUMMARY