From 19b81201b8d2a7620be03e580a20845700fd3621 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 8 Aug 2026 15:07:18 +0000 Subject: [PATCH 1/2] Add GitHub Action to mirror repository to Gitea 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 --- .github/workflows/mirror-to-gitea.yml | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/mirror-to-gitea.yml diff --git a/.github/workflows/mirror-to-gitea.yml b/.github/workflows/mirror-to-gitea.yml new file mode 100644 index 0000000..2a799f3 --- /dev/null +++ b/.github/workflows/mirror-to-gitea.yml @@ -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" From 3a0e02d9e0fd0660d79975465dd49cbe5263d675 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 8 Aug 2026 15:18:22 +0000 Subject: [PATCH 2/2] Fix Gitea mirror by skipping GitHub pull refs Push only refs/heads and refs/tags so Gitea no longer rejects refs/pull/* with "hook declined" and fails the mirror job. Co-authored-by: Diaco Soltanpour --- .github/workflows/mirror-to-gitea.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/mirror-to-gitea.yml b/.github/workflows/mirror-to-gitea.yml index 2a799f3..fa77af3 100644 --- a/.github/workflows/mirror-to-gitea.yml +++ b/.github/workflows/mirror-to-gitea.yml @@ -34,9 +34,9 @@ jobs: 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" + # Push only branches/tags. Never push GitHub refs/pull/* — Gitea + # rejects those with "hook declined" and fails the whole mirror. + git push --prune \ + "https://rhino:${GITEA_TOKEN}@git.faryad.top/rhino/xlsx-clean.git" \ + "+refs/heads/*:refs/heads/*" \ + "+refs/tags/*:refs/tags/*"