← Files anewARCHIVED FILE
.github/workflows/mirror-skill.yml
3.52 KB · Nov 20, 2026 · 06:27 UTC
# skills/anew/SKILL.md is not edited here. It is composed by the source that also serves it, and this
# job copies the served bytes back into the repo — the first hand-written copy drifted within ten days,
# which is the whole reason the file is derived now.
#
# The copy is only as trustworthy as the fetch, so the bytes are checked against the digest the skills
# index publishes for them before anything is committed. A captive portal, an error page or a partial
# response fails that comparison and nothing is written.
name: Mirror the served skill
on:
# The deploy that changes the skill runs this by hand (`npm run deploy`), so the mirror moves with
# the release rather than a day behind it. The schedule is the backstop for a deploy from elsewhere.
workflow_dispatch:
schedule:
- cron: '17 6 * * *'
permissions:
contents: write
# One mirror at a time: a nudge from a deploy and the nightly run landing together would race on the push.
concurrency:
group: mirror-skill
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Fetch the served skill and verify its published digest
run: |
set -euo pipefail
attempts=6
for attempt in $(seq 1 $attempts); do
curl -fsS --retry 3 --retry-all-errors -o skill.fetched \
https://anew.page/.well-known/agent-skills/anew/SKILL.md
curl -fsS --retry 3 --retry-all-errors -o index.fetched \
https://anew.page/.well-known/agent-skills/index.json
published=$(jq -er '.skills[] | select(.name == "anew") | .digest' index.fetched)
actual="sha256:$(sha256sum skill.fetched | cut -d ' ' -f 1)"
if [ "$published" = "$actual" ]; then
break
fi
# Expected while a deploy is still propagating: the two documents can come from edges on
# either side of the release, and the digest is the only thing that can tell. Waiting is
# the fix — a mismatch that outlives the loop is a real one and fails the job.
echo "::notice::attempt $attempt/$attempts — the index publishes $published, the bytes hash to $actual"
if [ "$attempt" = "$attempts" ]; then
echo "::error::the served skill never matched its published digest; the repo copy is untouched"
exit 1
fi
sleep 15
done
echo "SKILL_DIGEST=$actual" >> "$GITHUB_ENV"
mv skill.fetched skills/anew/SKILL.md
rm index.fetched
- name: Commit if the mirror moved
run: |
set -euo pipefail
path=skills/anew/SKILL.md
if git diff --quiet -- "$path"; then
echo "the repo copy already is the served skill"
exit 0
fi
# The message is read off the diff it records: how far the file moved in the subject,
# the source and its verified digest in the body.
adds=$(git diff --numstat -- "$path" | cut -f 1)
dels=$(git diff --numstat -- "$path" | cut -f 2)
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git commit -F - -- "$path" <<EOF
SKILL.md update (+$adds/-$dels)
anew.page now serves these bytes at
https://anew.page/.well-known/agent-skills/anew/SKILL.md — they matched
$SKILL_DIGEST, the digest the skills index publishes, before this
commit was made.
EOF
git push
SHA-256: 963f5954cca9097364674684865abb34cf27a25617446bb5c6b41c97d14dd865