Federated via graft
1.5 kB
28 lines
1name: push-github
2on:
3 push:
4 branches: [main]
5
6jobs:
7 mirror:
8 runs-on: linux-host
9 steps:
10 - name: clone and push to GitHub
11 run: |
12 set -e
13 rm -rf /tmp/graft-mirror
14 git clone --bare https://f1.cyberwild.org/forgeadmin/graft.git /tmp/graft-mirror
15 cd /tmp/graft-mirror
16 git push "https://x-access-token:${{ secrets.GH_PUSH_TOKEN }}@github.com/jeanbaptiste/graft.git" main:main
17 rm -rf /tmp/graft-mirror
18 - name: notify admin on failure
19 if: failure()
20 run: |
21 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 — 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}'}))")
22 curl -s -X POST \
23 -H "Authorization: token ${{ secrets.F1_ISSUE_TOKEN }}" \
24 -H "Content-Type: application/json" \
25 --data "$BODY" \
26 "https://f1.cyberwild.org/api/v1/repos/forgeadmin/graft/issues" \
27 -o /tmp/issue-create-resp.json -w "issue create HTTP: %{http_code}\n"
28 cat /tmp/issue-create-resp.json