add github sync flow
All checks were successful
Mirror to GitHub / mirror (push) Successful in 8s

This commit is contained in:
JonaKl
2026-03-23 14:42:45 +01:00
parent dc56a7cf53
commit 67c0624079

View 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