|
| 1 | +# check-skills.yml — Drop this into your library repo's .github/workflows/ |
| 2 | +# |
| 3 | +# Validates intent skills on PRs. After a release or manual run, opens or |
| 4 | +# updates one review PR when existing skills, artifact coverage, or workspace |
| 5 | +# package coverage need review. |
| 6 | +# |
| 7 | +# Triggers: pull requests touching skills/artifacts, new release published, or |
| 8 | +# manual workflow_dispatch. |
| 9 | +# |
| 10 | +# intent-workflow-version: 3 |
| 11 | +# |
| 12 | +# Template variables (replaced by `intent setup`): |
| 13 | +# text-compress — e.g. @tanstack/query or my-workspace workspace |
| 14 | + |
| 15 | +name: Check Skills |
| 16 | + |
| 17 | +on: |
| 18 | + pull_request: |
| 19 | + paths: |
| 20 | + - 'skills/**' |
| 21 | + - '**/skills/**' |
| 22 | + - '_artifacts/**' |
| 23 | + - '**/_artifacts/**' |
| 24 | + release: |
| 25 | + types: [published] |
| 26 | + workflow_dispatch: {} |
| 27 | + |
| 28 | +permissions: |
| 29 | + contents: write |
| 30 | + pull-requests: write |
| 31 | + |
| 32 | +jobs: |
| 33 | + validate: |
| 34 | + name: Validate intent skills |
| 35 | + if: github.event_name == 'pull_request' |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: Setup Node |
| 42 | + uses: actions/setup-node@v4 |
| 43 | + with: |
| 44 | + node-version: 20 |
| 45 | + |
| 46 | + - name: Install intent |
| 47 | + run: npm install -g @tanstack/intent |
| 48 | + |
| 49 | + - name: Validate skills |
| 50 | + run: intent validate --github-summary |
| 51 | + |
| 52 | + review: |
| 53 | + name: Check intent skill coverage |
| 54 | + if: github.event_name != 'pull_request' |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v4 |
| 59 | + with: |
| 60 | + fetch-depth: 0 |
| 61 | + |
| 62 | + - name: Setup Node |
| 63 | + uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: 20 |
| 66 | + |
| 67 | + - name: Install intent |
| 68 | + run: npm install -g @tanstack/intent |
| 69 | + |
| 70 | + - name: Check skills |
| 71 | + id: stale |
| 72 | + run: | |
| 73 | + intent stale --github-review --package-label "text-compress" |
| 74 | +
|
| 75 | + - name: Open or update review PR |
| 76 | + if: steps.stale.outputs.has_review == 'true' |
| 77 | + env: |
| 78 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + run: | |
| 80 | + VERSION="${{ github.event.release.tag_name || 'manual' }}" |
| 81 | + BRANCH="skills/review-${VERSION}" |
| 82 | + BASE_BRANCH="${{ github.event.repository.default_branch }}" |
| 83 | +
|
| 84 | + git config user.name "github-actions[bot]" |
| 85 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 86 | +
|
| 87 | + git fetch origin "$BRANCH" || true |
| 88 | + if git show-ref --verify --quiet "refs/remotes/origin/$BRANCH"; then |
| 89 | + git checkout -B "$BRANCH" "origin/$BRANCH" |
| 90 | + else |
| 91 | + git checkout -b "$BRANCH" |
| 92 | + git commit --allow-empty -m "chore: review intent skills for ${VERSION}" |
| 93 | + git push origin "$BRANCH" |
| 94 | + fi |
| 95 | +
|
| 96 | + PR_URL="$(gh pr list --head "$BRANCH" --json url --jq '.[0].url')" |
| 97 | + if [ -n "$PR_URL" ]; then |
| 98 | + gh pr edit "$PR_URL" --body-file pr-body.md |
| 99 | + else |
| 100 | + gh pr create \ |
| 101 | + --title "Review intent skills (${VERSION})" \ |
| 102 | + --body-file pr-body.md \ |
| 103 | + --head "$BRANCH" \ |
| 104 | + --base "$BASE_BRANCH" |
| 105 | + fi |
0 commit comments