ci: bidirectional mirror between GitHub and Gitea
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
Executable
+22
@@ -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"
|
||||
Reference in New Issue
Block a user