name: Mirror GitHub repos to Gitea on: schedule: # Runs at 00:00 UTC daily. Adjust if you want midnight EAT (UTC+3) instead — see note below. - cron: "0 0 * * *" workflow_dispatch: inputs: debug_http: description: "Print request/response headers for every Gitea write call" type: boolean default: false jobs: mirror: runs-on: ubuntu-latest steps: - name: Checkout (for the script) uses: actions/checkout@v5 - name: Install jq run: sudo apt-get update && sudo apt-get install -y jq # The mirror runs from a GitHub runner, not from the network the script is # usually tested on, so it can reach Gitea through a different proxy path. # This POSTs a harmless JSON body and reports whether Content-Type survived # the trip — a 422 "Empty Content-Type" here means the header is being # dropped in front of Gitea, not that the mirror payload is wrong. - name: Preflight - can this runner POST JSON to Gitea? env: GITEA_URL: ${{ secrets.GITEA_URL }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | url="${GITEA_URL%/}" echo "GET /api/v1/version -> $(curl -s -o /dev/null -w '%{http_code}' \ -H "Authorization: token ${GITEA_TOKEN}" "${url}/api/v1/version")" for proto in --http2 --http1.1; do code=$(curl -s $proto -o /tmp/pre.json -w '%{http_code}' \ -X POST "${url}/api/v1/markdown" \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/json" \ -H "Expect:" \ --data-binary '{"text":"preflight","mode":"markdown"}') echo "POST /api/v1/markdown ${proto} -> ${code}" [ "$code" = "200" ] || head -c 300 /tmp/pre.json; echo done - name: Mirror all repos to Gitea env: GITHUB_TOKEN: ${{ secrets.GH_PAT }} GITEA_URL: ${{ secrets.GITEA_URL }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_OWNER: ${{ secrets.GITEA_OWNER }} DEBUG_HTTP: ${{ inputs.debug_http && '1' || '' }} run: ./mirror-github-to-gitea.sh