name: push-github on: push: branches: [main] jobs: mirror: runs-on: linux-host steps: - name: clone and push to GitHub, notify f1 on failure run: | set +e rm -rf /tmp/graft-mirror git clone --bare https://f1.cyberwild.org/forgeadmin/graft.git /tmp/graft-mirror cd /tmp/graft-mirror git push "https://x-access-token:${{ secrets.GH_PUSH_TOKEN }}@github.com/jeanbaptiste/graft.git" main:main PUSH_STATUS=$? cd / rm -rf /tmp/graft-mirror if [ "$PUSH_STATUS" -ne 0 ]; then echo "push to GitHub failed (status $PUSH_STATUS) — notifying f1" BODY=$(python3 -c "import json; print(json.dumps({'title': 'CI: push to GitHub failed (run ${GITHUB_RUN_NUMBER})', 'body': 'push-github failed to mirror main to GitHub, exit status $PUSH_STATUS. Most likely someone pushed directly to GitHub, causing a divergence a plain git push refuses to overwrite.\n\nResolve manually: compare https://github.com/jeanbaptiste/graft and https://f1.cyberwild.org/forgeadmin/graft/src/branch/main, reconcile, then push.\n\nRun: https://f1.cyberwild.org/forgeadmin/graft/actions/runs/${GITHUB_RUN_NUMBER}'}))") curl -s -X POST \ -H "Authorization: token ${{ secrets.F1_ISSUE_TOKEN }}" \ -H "Content-Type: application/json" \ --data "$BODY" \ "https://f1.cyberwild.org/api/v1/repos/forgeadmin/graft/issues" \ -o /tmp/issue-create-resp.json -w "issue create HTTP: %{http_code}\n" cat /tmp/issue-create-resp.json exit 1 fi echo "pushed to GitHub ok"