This commit is contained in:
39
.gitea/workflows/github-sync.yaml
Normal file
39
.gitea/workflows/github-sync.yaml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: Mirror to GitHub
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
mirror:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config user.name "gitea-mirror"
|
||||||
|
git config user.email "mirror@example.com"
|
||||||
|
|
||||||
|
- name: Add GitHub remote
|
||||||
|
env:
|
||||||
|
MIRROR_REPO: ${{ vars.MIRROR_REPO }}
|
||||||
|
MIRROR_TOKEN: ${{ secrets.MIRROR_TOKEN }}
|
||||||
|
run: |
|
||||||
|
if [ -z "$MIRROR_REPO" ] || [ -z "$MIRROR_TOKEN" ]; then
|
||||||
|
echo "Missing required secrets: MIRROR_REPO and/or MIRROR_TOKEN"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git remote add github "https://x-access-token:${MIRROR_TOKEN}@github.com/${MIRROR_REPO}.git" || \
|
||||||
|
git remote set-url github "https://x-access-token:${MIRROR_TOKEN}@github.com/${MIRROR_REPO}.git"
|
||||||
|
|
||||||
|
- name: Push branches
|
||||||
|
run: |
|
||||||
|
git for-each-ref --format='%(refname:short)' refs/heads | while read branch; do
|
||||||
|
git push --force --prune github "refs/heads/$branch:refs/heads/$branch" || exit 1
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Push tags
|
||||||
|
run: git push --tags github --force
|
||||||
|
|
||||||
Reference in New Issue
Block a user