Federated via graft
0

Configure Feed

Select the types of activity you want to include in your feed.

CI: fix notify step — avoid unsupported if: failure() syntax, use plain bash branching

+18 -13
+18 -13
.forgejo/workflows/push-github.yml
··· 7 7 mirror: 8 8 runs-on: linux-host 9 9 steps: 10 - - name: clone and push to GitHub 10 + - name: clone and push to GitHub, notify f1 on failure 11 11 run: | 12 - set -e 12 + set +e 13 13 rm -rf /tmp/graft-mirror 14 14 git clone --bare https://f1.cyberwild.org/forgeadmin/graft.git /tmp/graft-mirror 15 15 cd /tmp/graft-mirror 16 16 git push "https://x-access-token:${{ secrets.GH_PUSH_TOKEN }}@github.com/jeanbaptiste/graft.git" main:main 17 + PUSH_STATUS=$? 18 + cd / 17 19 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 20 + 21 + if [ "$PUSH_STATUS" -ne 0 ]; then 22 + echo "push to GitHub failed (status $PUSH_STATUS) — notifying f1" 23 + 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}'}))") 24 + curl -s -X POST \ 25 + -H "Authorization: token ${{ secrets.F1_ISSUE_TOKEN }}" \ 26 + -H "Content-Type: application/json" \ 27 + --data "$BODY" \ 28 + "https://f1.cyberwild.org/api/v1/repos/forgeadmin/graft/issues" \ 29 + -o /tmp/issue-create-resp.json -w "issue create HTTP: %{http_code}\n" 30 + cat /tmp/issue-create-resp.json 31 + exit 1 32 + fi 33 + echo "pushed to GitHub ok"