1
0
Fork 0

Merge branch 'config' into localApps

# Conflicts:
#	.github/workflows/sync.yml
This commit is contained in:
pooneyy 2026-03-03 01:06:25 +08:00
commit 6949a2dbbe
No known key found for this signature in database
3 changed files with 281 additions and 85 deletions

146
.github/workflows/sync-auto.yml vendored Normal file
View File

@ -0,0 +1,146 @@
name: 同步仓库到其它远程仓库
on:
push:
branches:
- localApps
workflow_run:
workflows:
- 'App Version CI/CD'
types:
- completed
branches:
- renovate/*
permissions:
contents: read
jobs:
ssh-sync:
name: 同步到 ${{ matrix.remote.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
remote:
- 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
ssh-host: gitea.com
ssh-url: git@gitea.com:pooneyy/1Panel-Appstore.git
https-url: https://gitea.com/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

135
.github/workflows/sync-schedule.yml vendored Normal file
View File

@ -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

View File

@ -1,85 +0,0 @@
name: 同步仓库到其它远程仓库
on:
push:
branches:
- localApps
workflow_run:
workflows:
- 'App Version CI/CD'
types:
- completed
branches:
- renovate/*
permissions:
contents: read
jobs:
sync:
name: 同步到 ${{ matrix.remote.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
remote:
- 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
ssh-host: gitea.com
ssh-url: git@gitea.com:pooneyy/1Panel-Appstore.git
https-url: https://gitea.com/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-keyscan ${{ matrix.remote.ssh-host }} >> ~/.ssh/known_hosts
- 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.ssh-host }} ${{ 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 --force --prune ${{ matrix.remote.ssh-host }} --all
echo "将所有 tags 推送到 ${{ matrix.remote.name }}..."
git push --force ${{ matrix.remote.ssh-host }} --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