|
| 1 | +name: Sync agent skills from sei-skill |
| 2 | + |
| 3 | +# The installable agent skills at .mintlify/skills/<name>/SKILL.md are GENERATED |
| 4 | +# from the canonical sei-skill repo (github.com/sei-protocol/sei-skill) by |
| 5 | +# scripts/build-mintlify-skills.mjs — they are never hand-authored here. This |
| 6 | +# workflow regenerates them and opens a PR for review (generation is LLM-assisted |
| 7 | +# and non-deterministic, so a human reviews before merge). |
| 8 | +# |
| 9 | +# Triggers: |
| 10 | +# - workflow_dispatch (manual; optionally pass a sei-skill ref) |
| 11 | +# - repository_dispatch (sei-skill's release workflow sends type: sei-skill-release |
| 12 | +# with client_payload.ref = the released tag/sha) |
| 13 | +# |
| 14 | +# Requires repo secret ANTHROPIC_API_KEY and repo variable ANTHROPIC_MODEL (a |
| 15 | +# current model ID). |
| 16 | + |
| 17 | +on: |
| 18 | + workflow_dispatch: |
| 19 | + inputs: |
| 20 | + ref: |
| 21 | + description: 'sei-skill ref to generate from' |
| 22 | + required: false |
| 23 | + default: 'main' |
| 24 | + repository_dispatch: |
| 25 | + types: [sei-skill-release] |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: write |
| 29 | + pull-requests: write |
| 30 | + |
| 31 | +defaults: |
| 32 | + run: |
| 33 | + shell: bash |
| 34 | + |
| 35 | +jobs: |
| 36 | + sync: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + timeout-minutes: 20 |
| 39 | + steps: |
| 40 | + - name: Checkout docs |
| 41 | + uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Checkout sei-skill (canonical source) |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + repository: sei-protocol/sei-skill |
| 47 | + ref: ${{ github.event.client_payload.ref || inputs.ref || 'main' }} |
| 48 | + path: .sei-skill-src |
| 49 | + |
| 50 | + - name: Set up Node |
| 51 | + uses: actions/setup-node@v4 |
| 52 | + with: |
| 53 | + node-version: '20' |
| 54 | + |
| 55 | + - name: Install generator dependency |
| 56 | + run: npm install --no-save @anthropic-ai/sdk@0.129.0 |
| 57 | + |
| 58 | + - name: Record sei-skill revision |
| 59 | + id: src |
| 60 | + run: echo "ref=$(git -C .sei-skill-src rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" |
| 61 | + |
| 62 | + - name: Regenerate skills from sei-skill |
| 63 | + env: |
| 64 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 65 | + ANTHROPIC_MODEL: ${{ vars.ANTHROPIC_MODEL }} |
| 66 | + SEI_SKILL_DIR: ${{ github.workspace }}/.sei-skill-src/skill |
| 67 | + SEI_SKILL_REF: ${{ steps.src.outputs.ref }} |
| 68 | + run: node scripts/build-mintlify-skills.mjs --write |
| 69 | + |
| 70 | + - name: Clean up source + build dirs |
| 71 | + run: rm -rf .sei-skill-src dist |
| 72 | + |
| 73 | + # PRs opened with GITHUB_TOKEN don't trigger other workflows, so the sync PR |
| 74 | + # never runs validate-docs.yml or link-check.yml. Run their skill checks here. |
| 75 | + - name: Validate regenerated skills |
| 76 | + run: | |
| 77 | + node scripts/check-skills.mjs |
| 78 | + npx --yes mint@4.2.952 broken-links |
| 79 | +
|
| 80 | + - name: Open PR if skills changed |
| 81 | + env: |
| 82 | + GH_TOKEN: ${{ github.token }} |
| 83 | + run: | |
| 84 | + set -euo pipefail |
| 85 | + # Stage first: `git diff --quiet` ignores untracked files, so a brand-new |
| 86 | + # skill (or a first run into an empty .mintlify/skills/) would be missed. |
| 87 | + git add .mintlify/skills |
| 88 | + if git diff --cached --quiet; then |
| 89 | + echo 'No skill changes; nothing to do.' |
| 90 | + exit 0 |
| 91 | + fi |
| 92 | + BRANCH="chore/sync-skills-${{ steps.src.outputs.ref }}" |
| 93 | + # A reviewer may have pushed fixups to an open sync PR for this ref; |
| 94 | + # a force-push would silently discard them. |
| 95 | + if [[ -n "$(gh pr list --head "$BRANCH" --state open --json number --jq '.[].number')" ]]; then |
| 96 | + echo "An open PR already syncs sei-skill@${{ steps.src.outputs.ref }}; leaving it untouched." |
| 97 | + exit 0 |
| 98 | + fi |
| 99 | + git config user.name 'github-actions[bot]' |
| 100 | + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' |
| 101 | + git checkout -b "$BRANCH" |
| 102 | + git commit -m "chore(skills): regenerate from sei-skill@${{ steps.src.outputs.ref }}" |
| 103 | + # Overwrites a leftover branch from a closed sync PR for the same ref. |
| 104 | + git push -f origin "$BRANCH" |
| 105 | + new_pr=$(gh pr create \ |
| 106 | + --title "chore(skills): regenerate from sei-skill@${{ steps.src.outputs.ref }}" \ |
| 107 | + --body "Automated regeneration of \`.mintlify/skills/\` from [sei-protocol/sei-skill](https://github.com/sei-protocol/sei-skill)@${{ steps.src.outputs.ref }} via \`scripts/build-mintlify-skills.mjs\`. These are generated artifacts — review for quality before merge.") |
| 108 | + # Close open sync PRs for older refs, so two PRs never rewrite the same skills. |
| 109 | + # Their branches stay, so a reviewer's fixups there can still be ported. |
| 110 | + gh pr list --state open --limit 100 --json number,headRefName | |
| 111 | + jq -r --arg branch "$BRANCH" '.[] | select((.headRefName | startswith("chore/sync-skills-")) and .headRefName != $branch) | .number' | |
| 112 | + while read -r number; do |
| 113 | + gh pr close "$number" --comment "Superseded by $new_pr, which syncs sei-skill@${{ steps.src.outputs.ref }}. This branch is kept, so any fixups here can be ported." |
| 114 | + done |
0 commit comments