← Files AMDARCHIVED FILE
.github/workflows/federate-skills.yml
6.96 KB · Nov 21, 2026 · 12:39 UTC
name: federate-skills
# Keeps the vendored copies under `skills/` in step with the source repos
# declared in `.github/federation.json`. Runs nightly and on demand.
#
# `federate_skills.py` clones each declared repo at its tracked branch (`main`
# unless the entry sets `branch`; a pattern such as `release/*` resolves to the
# newest release branch) and re-vendors a
# skill only when the contents of its upstream folder changed, so a night
# with no upstream activity produces no diff and no pull request. When
# something did change, the run opens a pull request titled
# "Bump `<skill>` to `<commit>`" that touches `skills/` only. The marketplace
# and plugin manifests are edited by hand, never by this workflow. Validating
# the result is the `validate` workflow's job on that pull request, not this
# workflow's.
#
# Every skill gets its own job, branch, and pull request, so two upstream
# changes on the same night are reviewed, merged, or reverted independently,
# and one source failing to clone does not hold back the others' bumps.
#
# The pull request always targets `main`, whatever branch the run was
# dispatched from, and the run always uses the dispatched branch's copy of the
# scripts. So a test dispatch from a side branch exercises that branch's
# federation code while still proposing the bump where it belongs.
#
# See the "Catalog federation" section of `README.md` for the design and
# `CONTRIBUTING.md` for the federation file's schema.
on:
schedule:
# 06:17 UTC nightly. Off the hour so the run isn't queued behind the
# crowd of jobs scheduled at :00.
- cron: "17 6 * * *"
workflow_dispatch:
inputs:
only:
description: "Limit the run to one local skill name (e.g. tracelens-analysis-orchestrator)."
required: false
type: string
permissions:
contents: write
pull-requests: write
concurrency:
group: federate-skills
cancel-in-progress: false
env:
BASE_BRANCH: main
# Each skill's pull request lives on `<prefix><skill>`. The prefix must not
# be an existing branch name, since git cannot hold both `a` and `a/b`.
PR_BRANCH_PREFIX: bot/federate/
jobs:
# Reads the federation file only; nothing is cloned here. An unknown `only`
# name or an invalid federation file fails the run at this step.
plan:
name: List federated skills
runs-on: ubuntu-latest
outputs:
skills: ${{ steps.list.outputs.skills }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: List skills declared in .github/federation.json
id: list
env:
ONLY: ${{ inputs.only }}
run: |
args=(--list-skills)
if [ -n "$ONLY" ]; then args+=(--only "$ONLY"); fi
skills="$(uv run .github/scripts/federate_skills.py "${args[@]}")"
echo "Skills to check: $skills"
echo "skills=$skills" >> "$GITHUB_OUTPUT"
federate:
name: Federate ${{ matrix.skill }}
needs: plan
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
skill: ${{ fromJSON(needs.plan.outputs.skills) }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v7
# `--only` leaves every other skill untouched, so this job's diff is this
# skill's alone.
- name: Vendor ${{ matrix.skill }}
id: federate
env:
# Written outside the work tree so the summary never shows up as a
# repository change.
SUMMARY: ${{ runner.temp }}/federation-summary.json
SKILL: ${{ matrix.skill }}
run: |
uv run .github/scripts/federate_skills.py --only "$SKILL" --summary-json "$SUMMARY"
{
echo "title=$(jq -r '.title' "$SUMMARY")"
echo "body<<FEDERATION_BODY_EOF"
jq -r '.body' "$SUMMARY"
echo "FEDERATION_BODY_EOF"
} >> "$GITHUB_OUTPUT"
# Unchanged skills are left byte-for-byte alone (a marker-only
# difference is reverted by the importer), so an empty work tree here is
# the authoritative "nothing to federate" signal. Nothing to federate is
# a successful outcome, not a failure.
- name: Detect changes
id: changes
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
git status --short
fi
# Push to a dedicated per-skill branch and open a PR rather than
# committing to main, so vendored changes stay reviewable and the
# standard `validate` workflow gates them. Re-running updates that
# skill's PR in place.
#
# `base` is pinned rather than left to default, because the default is the
# branch the run was dispatched from: a manual dispatch off a side branch
# would otherwise open a pull request targeting that side branch. The
# action rebases the vendored changes onto `base` for us.
- name: Open pull request
id: pr
if: ${{ steps.changes.outputs.changed == 'true' }}
uses: peter-evans/create-pull-request@v7
with:
base: ${{ env.BASE_BRANCH }}
branch: ${{ env.PR_BRANCH_PREFIX }}${{ matrix.skill }}
delete-branch: true
commit-message: ${{ steps.federate.outputs.title || format('Refresh federated skill `{0}`', matrix.skill) }}
title: ${{ steps.federate.outputs.title || format('Refresh federated skill `{0}`', matrix.skill) }}
body: |
${{ steps.federate.outputs.body }}
Opened by the `federate-skills` workflow ([run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})).
labels: |
catalog
automated
add-paths: |
skills/**
# Say plainly what happened, in the log and on the run's summary page.
# "Nothing changed upstream" is the expected result most nights and has
# to read as a success rather than as a job that quietly did nothing.
- name: Report outcome
env:
SKILL: ${{ matrix.skill }}
CHANGED: ${{ steps.changes.outputs.changed }}
TITLE: ${{ steps.federate.outputs.title }}
PR_URL: ${{ steps.pr.outputs.pull-request-url }}
PR_OPERATION: ${{ steps.pr.outputs.pull-request-operation }}
run: |
if [ "$CHANGED" != "true" ]; then
message="\`$SKILL\` already matches its source repo at its tracked branch. No pull request needed."
elif [ -n "$PR_URL" ]; then
message="Pull request ${PR_OPERATION:-ready}: ${TITLE:-Refresh federated skill \`$SKILL\`} ($PR_URL)"
else
message="Changes were detected for \`$SKILL\` but no pull request was opened, because none of them fall under the paths this workflow commits."
fi
echo "$message"
echo "$message" >> "$GITHUB_STEP_SUMMARY"
SHA-256: 2be1f76b61f161bd71fc020eca76270920f76784a075df49ddba00be9dc1f5ed