-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix: gate issue-to-PR behind label with permission checks #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ name: Issue to PR | |
|
|
||
| on: | ||
| issues: | ||
| types: [opened] | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
@@ -29,8 +29,9 @@ jobs: | |
| name: Validate Issue | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| # Skip bot-created issues | ||
| # Only run when 'ai-implement' label is applied; skip bot-created issues | ||
| if: >- | ||
| github.event.label.name == 'ai-implement' && | ||
| github.event.issue.user.login != 'claude[bot]' && | ||
| github.event.issue.user.login != 'github-actions[bot]' && | ||
| github.event.issue.user.login != 'dependabot[bot]' | ||
|
|
@@ -82,18 +83,33 @@ jobs: | |
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Verify actor permissions | ||
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 | ||
| with: | ||
| script: | | ||
| const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| username: context.actor | ||
| }); | ||
| const allowed = ['admin', 'write']; | ||
| if (!allowed.includes(data.permission)) { | ||
| core.setFailed(`Actor ${context.actor} has '${data.permission}' permission, needs 'write' or 'admin'`); | ||
| } | ||
| core.info(`Actor ${context.actor} verified with '${data.permission}' permission`); | ||
|
Comment on lines
+91
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Permission check may throw 404 for non-collaborators. The Consider wrapping in try-catch to provide a clearer error message for non-collaborators: 🛡️ Proposed fix to handle non-collaborator case - name: Verify actor permissions
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
- const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
- owner: context.repo.owner,
- repo: context.repo.repo,
- username: context.actor
- });
- const allowed = ['admin', 'write'];
- if (!allowed.includes(data.permission)) {
- core.setFailed(`Actor ${context.actor} has '${data.permission}' permission, needs 'write' or 'admin'`);
+ let permission;
+ try {
+ const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ username: context.actor
+ });
+ permission = data.permission;
+ } catch (error) {
+ if (error.status === 404) {
+ core.setFailed(`Actor ${context.actor} is not a collaborator on this repository`);
+ return;
+ }
+ throw error;
+ }
+ const allowed = ['admin', 'write'];
+ if (!allowed.includes(permission)) {
+ core.setFailed(`Actor ${context.actor} has '${permission}' permission, needs 'write' or 'admin'`);
}
- core.info(`Actor ${context.actor} verified with '${data.permission}' permission`);
+ core.info(`Actor ${context.actor} verified with '${permission}' permission`);🤖 Prompt for AI Agents |
||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v6 | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
|
|
@@ -182,7 +198,7 @@ jobs: | |
|
|
||
| - name: Upload patch artifact | ||
| if: steps.detect.outputs.has_changes == 'true' | ||
| uses: actions/upload-artifact@v7 | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify SHA pinning for artifact and PR actions
echo "=== actions/upload-artifact (claimed v7) ==="
gh api repos/actions/upload-artifact/tags --jq '.[] | select(.name | startswith("v7")) | "\(.name): \(.commit.sha)"' | head -3
echo -e "\n=== actions/download-artifact (claimed v8) ==="
gh api repos/actions/download-artifact/tags --jq '.[] | select(.name | startswith("v8")) | "\(.name): \(.commit.sha)"' | head -3
echo -e "\n=== peter-evans/create-pull-request (claimed v8) ==="
gh api repos/peter-evans/create-pull-request/tags --jq '.[] | select(.name | startswith("v8")) | "\(.name): \(.commit.sha)"' | head -3Repository: Tony363/SuperClaude Length of output: 594 🏁 Script executed: cat -n .github/workflows/issue-to-pr.yml | sed -n '195,210p; 230,240p; 340,350p; 370,390p'Repository: Tony363/SuperClaude Length of output: 2509 🌐 Web query:
💡 Result: The release commit SHA for actions/upload-artifact v7 (v7.0.0) is bbbca2d. This is the commit tagged for the v7.0.0 release, as shown on the GitHub tags page and release page. The v7 tag points to the same commit. Key changes include support for direct file uploads (PR Citations:
🌐 Web query:
💡 Result: The release commit SHA for actions/download-artifact v8 (specifically v8.0.0, released around 2026-02-26) is 974686e, corresponding to the commit "Bump the version to v8 and add release notes" by Daniel Kennedy on 2026-02-23. This is the commit that tagged the v8 release, as shown in the GitHub compare view v7...v8.0.0. The subsequent v8.0.1 release (2026-03-11) has commit 3e5f45b. Citations:
🌐 Web query:
💡 Result: The commit SHA for the v8 release (specifically v8.0.0) of peter-evans/create-pull-request is 98357b1. This is the commit to which the v8.0.0 tag points, titled "feat: v8 ( Citations:
SHA pinning discrepancy found for Verification confirms SHAs for most actions match their versions, with one exception:
The SHA 🤖 Prompt for AI Agents |
||
| with: | ||
| name: issue-fix-patch | ||
| path: /tmp/patch/issue-fix.patch | ||
|
|
@@ -208,15 +224,15 @@ jobs: | |
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v6 | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Download patch | ||
| uses: actions/download-artifact@v8 | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | ||
| with: | ||
| name: issue-fix-patch | ||
| path: /tmp/patch | ||
|
|
@@ -325,7 +341,7 @@ jobs: | |
|
|
||
| - name: Upload clean patch | ||
| if: steps.final.outputs.passed == 'true' | ||
| uses: actions/upload-artifact@v7 | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7 | ||
| with: | ||
| name: issue-fix-clean-patch | ||
| path: /tmp/clean-patch/issue-fix-clean.patch | ||
|
|
@@ -348,13 +364,13 @@ jobs: | |
| # ---- Success path ---- | ||
| - name: Checkout repository | ||
| if: needs.guardrails.outputs.passed == 'true' | ||
| uses: actions/checkout@v6 | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Download clean patch | ||
| if: needs.guardrails.outputs.passed == 'true' | ||
| uses: actions/download-artifact@v8 | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 | ||
| with: | ||
| name: issue-fix-clean-patch | ||
| path: /tmp/clean-patch | ||
|
|
@@ -366,7 +382,7 @@ jobs: | |
| - name: Create Draft PR | ||
| id: create | ||
| if: needs.guardrails.outputs.passed == 'true' | ||
| uses: peter-evans/create-pull-request@v8 | ||
| uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| branch: issue-fix/${{ github.event.issue.number }}-${{ github.run_id }} | ||
|
|
@@ -450,12 +466,12 @@ jobs: | |
|
|
||
| steps: | ||
| - name: Checkout scripts | ||
| uses: actions/checkout@v6 | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| sparse-checkout: .github/scripts | ||
|
|
||
| - name: Setup Python | ||
| uses: actions/setup-python@v6 | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Tony363/SuperClaude
Length of output: 487
🌐 Web query:
anthropics claude-code-action v1 release 58dbe8ed6879f0d3b02ac295b20d5fdfe7733e0c💡 Result:
The GitHub repository anthropics/claude-code-action is the official Claude Code GitHub Action from Anthropic, which integrates Claude Code (an agentic coding tool) into GitHub workflows for PR reviews, issue responses, code fixes, and automation. It supports
@claudementions, slash commands, and direct prompts. v1 (tag v1, released around August 2025, generally available by 2026-04-01 per release notes) is the major stable version introducing automatic mode detection, unified 'prompt' input, 'claude_args' for CLI options, breaking changes from beta/v0.x (e.g., deprecated 'mode', 'direct_prompt'), migration guide available, and examples for PR reviews/security scans/CI fixes. Latest patches like v1.0.86 (2026-04-02) include minor fixes (e.g., subprocess isolation, env passing). The hash 58dbe8ed6879f0d3b02ac295b20d5fdfe7733e0c does not appear in repository commits, releases, tags, or mirrors searched. No matching GitHub commits found across main branches, release tags, or forks. Not associated with people (LinkedIn) or source leak reports (which reference Claude Code CLI v2.1.88 source map, not this action). Likely an internal/private hash, file ID, or from unpublished/unindexed context.Citations:
🌐 Web query:
github anthropics/claude-code-action v1 tag commit SHA💡 Result:
The GitHub repository anthropics/claude-code-action has a tag named "v1" corresponding to the "Claude Code GitHub Action v1.0" release, announced as generally available. This is the initial v1.0 release published on 2025-08-26T17:01:10Z (with some metadata showing 2026-04-01 creation timestamp, likely an update). The exact commit SHA for the v1 tag is not explicitly stated in the search results. However, GitHub tag pages and tree views like https://github.com/anthropics/claude-code-action/tree/v1 would show the full SHA (e.g., similar to v1.0.27 tree view). Specific SHAs found for files on branches/tags include eb99fb38 (src/modes/tag/index.ts) and 9a3c761f (README.md), but these are not confirmed as the v1 tag commit. The repository has 146+ releases with latest v1.0.85 as of 2026-04-01, and v1 points to the v1.0 GA release commit. To get the precise SHA, visit https://github.com/anthropics/claude-code-action/releases/tag/v1 and note the commit hash displayed there, or use Git git rev-list -n 1 v1.
Citations:
The pinned SHA does not correspond to anthropics/claude-code-action v1.
The SHA
58dbe8ed6879f0d3b02ac295b20d5fdfe7733e0cdoes not appear in the public repository's commits, releases, or tags. This appears to be an invalid or internal commit hash. Use the actual v1 tag commit from https://github.com/anthropics/claude-code-action/releases/tag/v1 instead.🤖 Prompt for AI Agents