diff --git a/.gitea/workflows/sync-wrappers.yml b/.gitea/workflows/sync-wrappers.yml new file mode 100644 index 0000000..a843848 --- /dev/null +++ b/.gitea/workflows/sync-wrappers.yml @@ -0,0 +1,50 @@ +# Auto-PR canonical wrapper updates to consumer repos when wrappers/ changes on +# main. Maintenance automation (not artifact publishing), so it is allowed on a +# main push under the D7 trigger standard. Requires WRAPPER_SYNC_TOKEN: a bot +# user's token with content+PR write to the consumer repos (never committed). +name: sync-wrappers + +on: + push: + branches: [main] + paths: + - 'wrappers/crucible.sh' + - 'wrappers/crucible.ps1' + +jobs: + sync: + runs-on: nix-docker + steps: + - uses: actions/checkout@v4 + + - name: Open sync PRs to consumers + env: + TOKEN: ${{ secrets.WRAPPER_SYNC_TOKEN }} + SERVER: ${{ github.server_url }} + SRC_SHA: ${{ github.sha }} + run: | + nix develop --command bash -c ' + set -euo pipefail + host="$(echo "$SERVER" | sed -E "s#https?://##")" + branch="chore/sync-wrappers-$(echo "$SRC_SHA" | cut -c1-12)" + grep -vE "^\s*#|^\s*$" wrappers/consumers.txt | while read -r target; do + echo "== syncing $target ==" + work="$(mktemp -d)" + git clone "https://oauth2:${TOKEN}@${host}/${target}.git" "$work" + cp wrappers/crucible.sh wrappers/crucible.ps1 "$work"/ + ( cd "$work" + git config user.name "crucible-sync-bot" + git config user.email "bot@westgate.pw" + if git diff --quiet; then echo "no changes for $target"; exit 0; fi + git checkout -b "$branch" + git add crucible.sh crucible.ps1 + git commit -m "chore: sync crucible wrappers from sow-tools@${SRC_SHA}" + git push -f origin "$branch" + curl -fsS -X POST \ + -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" \ + "${SERVER}/api/v1/repos/${target}/pulls" \ + -d "{\"head\":\"${branch}\",\"base\":\"main\",\"title\":\"chore: sync crucible wrappers from sow-tools\"}" || true + ) + rm -rf "$work" + done + ' diff --git a/wrappers/consumers.txt b/wrappers/consumers.txt new file mode 100644 index 0000000..f1f7c0c --- /dev/null +++ b/wrappers/consumers.txt @@ -0,0 +1,5 @@ +# Repos that carry copies of the canonical Crucible wrappers. +# One "owner/repo" per line. sync-wrappers.yml opens an update PR to each when +# wrappers/ changes. Add a repo here AND grant the sync bot write access to it. +ShadowsOverWestgate/sow-module +ShadowsOverWestgate/sow-topdata