ci: bidirectional mirror between GitHub and Gitea

This commit is contained in:
SinachPat
2026-08-15 14:08:45 +01:00
parent 1f017cd9b0
commit bb84ab5aef
3 changed files with 66 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
name: Mirror to GitHub
on:
push:
branches: [main]
concurrency:
group: mirror
cancel-in-progress: true
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Reconcile with GitHub
run: bash scripts/mirror.sh
env:
MIRROR_URL: https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/SinachPat/wursor.git
+22
View File
@@ -0,0 +1,22 @@
name: Mirror to Gitea
on:
push:
branches: [main]
concurrency:
group: mirror
cancel-in-progress: true
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Reconcile with Gitea
run: bash scripts/mirror.sh
env:
MIRROR_URL: https://x-access-token:${{ secrets.GITEA_TOKEN }}@git.weown.tools/Wursor/s004.git
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
BRANCH="${BRANCH:-main}"
git config user.name "mirror-bot"
git config user.email "mirror-bot@noreply.local"
git remote remove mirror 2>/dev/null || true
git remote add mirror "$MIRROR_URL"
git fetch origin "$BRANCH"
git fetch mirror "$BRANCH"
if git rev-parse --verify -q "mirror/$BRANCH" >/dev/null; then
if ! git merge-base --is-ancestor "mirror/$BRANCH" HEAD; then
git merge --no-edit "mirror/$BRANCH"
fi
fi
git push origin "HEAD:$BRANCH"
git push mirror "HEAD:$BRANCH"