Add GitHub Action to mirror repository to Gitea
Some checks failed
Mirror to Gitea / mirror (push) Has been cancelled

Push all branches and tags to git.faryad.top after every GitHub ref
change so Gitea stays identical to GitHub when GITEA_TOKEN is set.

Co-authored-by: Diaco Soltanpour <s-diaco@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-08-08 15:07:18 +00:00
parent f1b99e5da9
commit 19b81201b8

42
.github/workflows/mirror-to-gitea.yml vendored Normal file
View File

@@ -0,0 +1,42 @@
# Mirror all branches and tags from GitHub → Gitea after every ref change.
# Requires repo secret GITEA_TOKEN (Gitea PAT with write:repository on rhino/xlsx-clean).
name: Mirror to Gitea
on:
push:
delete:
create:
workflow_dispatch:
concurrency:
group: mirror-to-gitea
cancel-in-progress: true
jobs:
mirror:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Mirror repository to Gitea
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if [ -z "${GITEA_TOKEN:-}" ]; then
echo "Missing secret GITEA_TOKEN (Gitea PAT with write:repository)." >&2
exit 1
fi
git clone --mirror \
"https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \
mirror.git
cd mirror.git
# Drop GitHub pull-request refs; Gitea should only get branches/tags.
git for-each-ref --format='%(refname)' 'refs/pull' \
| while read -r ref; do git update-ref -d "$ref"; done
git push --mirror \
"https://rhino:${GITEA_TOKEN}@git.faryad.top/rhino/xlsx-clean.git"