The long-lived token no longer lands in $WS/goodwe/.git/config (mounted into the tests' container, left behind by a failed job) or in git's argv. A missing secret (fork PR) fails with its own message. README: addon-pin is not re-run after a bump. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LyR88rXETvwhTgx6yHE39p
43 lines
2.1 KiB
YAML
43 lines
2.1 KiB
YAML
# CI-12: goes red when admin/goodwe release/1.0 has moved past .gitea/infra-pin.
|
|
# It runs on add-on activity only; admin/goodwe's own `addon-pin` workflow
|
|
# covers a move of release/1.0 there. Deliberately NOT a required check: it
|
|
# reports; `checks / unit` stays the only gate. How to bump: README.md,
|
|
# "CI and the infra pin".
|
|
name: infra-pin
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches: [release/1.0]
|
|
|
|
jobs:
|
|
fresh:
|
|
runs-on: [self-hosted, goodwe-rig]
|
|
timeout-minutes: 30 # seconds of work; the rest is queueing for the shared slot
|
|
steps:
|
|
- name: compare .gitea/infra-pin with admin/goodwe release/1.0
|
|
env:
|
|
SELF: ${{ github.server_url }}/${{ github.repository }}.git
|
|
INFRA: ${{ github.server_url }}/admin/goodwe.git
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
INFRA_TOKEN: ${{ secrets.INFRA_READ_TOKEN }} # admin/goodwe is private
|
|
run: |
|
|
set -eu
|
|
D=$(mktemp -d) && cd "$D"
|
|
git init -q . && git remote add origin "$(echo "$SELF" | sed "s#://#://x-access-token:${TOKEN}@#")"
|
|
# The pin of the commit this event is about (the PR head, or the push).
|
|
git fetch -q --depth 1 origin "$GITHUB_SHA"
|
|
PIN=$(git show FETCH_HEAD:.gitea/infra-pin | grep -v '^#' | tr -d '[:space:]')
|
|
test -n "$INFRA_TOKEN" || { echo "FAIL: secret INFRA_READ_TOKEN is not available to this run (a fork PR?)."; exit 1; }
|
|
# Header via env, as in checks.yml: the token stays out of argv.
|
|
HEAD=$(GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraHeader GIT_CONFIG_VALUE_0="Authorization: token $INFRA_TOKEN" \
|
|
git ls-remote "$INFRA" refs/heads/release/1.0 | cut -f1)
|
|
cd / && rm -rf "$D"
|
|
test -n "$HEAD" || { echo "FAIL: could not read admin/goodwe release/1.0."; exit 1; }
|
|
if [ "$PIN" != "$HEAD" ]; then
|
|
echo "STALE: .gitea/infra-pin is $PIN but admin/goodwe release/1.0 is $HEAD."
|
|
echo " Test against $HEAD and bump the pin (README.md, \"CI and the infra pin\")."
|
|
exit 1
|
|
fi
|
|
echo "OK: .gitea/infra-pin $PIN is admin/goodwe release/1.0 HEAD."
|