Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ jobs:
name: Check CLI schema is up to date
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max-old-space-size=6144
Expand All @@ -151,6 +152,14 @@ jobs:
echo "docs/cli/schema.json is out of date. Run 'npm run build:schema' and commit the result."
exit 1
fi
- name: Comment on PR
if: failure() && github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
gh pr comment "$PR_NUMBER" --body "<!-- schema-stale -->
\`docs/cli/schema.json\` is out of date. Comment \`/fix-schema\` on this PR and the bot will regenerate and commit it automatically."

ci:
name: CI Result
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/schema-auto-fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Auto-fix schema

on:
issue_comment:
types: [created]

jobs:
fix:
name: Regenerate and commit schema
if: github.event.issue.pull_request != null && contains(github.event.comment.body, '/fix-schema')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this contains rule get triggered when the ci.yml workflow posts Comment /fix-schema on this? Just making sure we avoid an infinite loop.

runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
NODE_OPTIONS: --max-old-space-size=6144
steps:
- name: Get PR branch
id: pr
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
BRANCH=$(gh pr view "$PR_NUMBER" --json headRefName -q .headRefName)
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"

- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
ref: ${{ steps.pr.outputs.branch }}

- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6

Check failure

Code scanning / CodeQL

Checkout of untrusted code in a privileged context Critical

Checkout of untrusted code in a privileged workflow with later potential execution (event trigger:
issue_comment
).
Checkout of untrusted code in a privileged workflow with later potential execution (event trigger:
issue_comment
).
Checkout of untrusted code in a privileged workflow with later potential execution (event trigger:
issue_comment
).
Comment on lines +27 to +31

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd take a look at the details on this one to make sure it not a real concern. Being able to trigger code execution by posting a comment on an issue or PR seems to be what it's flagging.

with:
node-version: 24.x

- name: Install
run: npm ci

- name: Build
run: npm run build

- name: Regenerate CLI schema
run: npm run build:schema

- name: Commit and push
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.issue.number }}
run: |
if git diff --quiet docs/cli/schema.json; then
gh pr comment "$PR_NUMBER" --body "Schema is already up to date - nothing to commit."
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/cli/schema.json
git commit -m "chore: regenerate CLI schema"
git push
gh pr comment "$PR_NUMBER" --body "Schema regenerated and committed."
fi
Loading