Repository navigation
ci: migrate workflow auth from PAT to GitHub App tokens - #3004
Conversation
Switch draft-stale-prs and label-rebase-prs workflows from using PR_RW_GITHUB_TOKEN (personal access token) to generating tokens via the Dyad GitHub App, improving security and auditability. Co-Authored-By: Claude <[email protected]>
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
|
@BugBot run |
| permission-contents: read | ||
| permission-pull-requests: write |
There was a problem hiding this comment.
π΄ Missing permission-issues: write on app token causes issues.addLabels to fail
The label-rebase-prs.yml workflow creates a GitHub App token with only permission-contents: read and permission-pull-requests: write, but the script calls github.rest.issues.addLabels at line 74, which uses the POST /repos/{owner}/{repo}/issues/{issue_number}/labels endpoint. This endpoint requires the issues: write permission for GitHub Apps. Without it, the addLabels call will fail with a 403 permission error whenever the workflow tries to label a conflicting PR. The sibling workflow draft-stale-prs.yml correctly includes permission-issues: write (line 26), so this appears to be an oversight.
| permission-contents: read | |
| permission-pull-requests: write | |
| permission-contents: read | |
| permission-pull-requests: write | |
| permission-issues: write | |
Was this helpful? React with π or π to provide feedback.
π Dyadbot Code Review SummaryVerdict: β YES - Ready to merge Reviewed by 3 independent agents: Correctness Expert, Code Health Expert, UX Wizard. Clean, straightforward migration from PAT-based auth to GitHub App tokens. The changes are consistent across both workflow files, permissions are appropriately scoped, and the pattern follows best practices for GitHub Actions auth. Issues SummaryNo HIGH or MEDIUM issues found. π’ Low Priority Notes (1 item)
π« Dropped False Positives (3 items)
Generated by Dyadbot multi-agent code review |
Greptile SummaryThis PR improves the CI security posture by replacing long-lived personal access tokens (
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Runner as GitHub Actions Runner
participant TokenAction as create-github-app-token
participant GitHubApp as Dyad GitHub App
participant ScriptAction as github-script
participant API as GitHub REST/GraphQL API
Runner->>TokenAction: app-id + private-key (scoped permissions)
TokenAction->>GitHubApp: JWT exchange for installation token
GitHubApp-->>TokenAction: Short-lived scoped token
TokenAction-->>Runner: outputs.token
Runner->>ScriptAction: Pass App token as github-token
ScriptAction->>API: Authenticated REST and GraphQL calls
API-->>ScriptAction: Responses (PR updates, labels, comments)
Prompt To Fix All With AIThis is a comment left during a code review.
Path: .github/workflows/label-rebase-prs.yml
Line: 22-23
Comment:
**Missing `issues: write` permission for label operations**
The `github.rest.issues.addLabels` call (line 74) uses the GitHub Issues REST API (`POST /repos/{owner}/{repo}/issues/{issue_number}/labels`). GitHub Apps require the `issues: write` permission to manage labels on issues and pull requests β `pull_requests: write` alone is not sufficient for this endpoint.
The `draft-stale-prs.yml` workflow correctly requests `permission-issues: write` for its comment creation (`issues.createComment`). By analogy, this workflow also needs `issues: write` for label management.
Without this permission, the App token will likely receive a `403 Forbidden` response when attempting to add the `cc:rebase` label.
```suggestion
permission-contents: read
permission-pull-requests: write
permission-issues: write
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: .github/workflows/draft-stale-prs.yml
Line: 8-11
Comment:
**Stale workflow-level `permissions` block**
Now that all privileged operations use the GitHub App token (from `steps.app-token.outputs.token`) rather than the built-in `GITHUB_TOKEN`, the top-level `permissions` block only applies to `GITHUB_TOKEN`, which is no longer used for any write operations. `pull-requests: write` and `issues: write` are therefore granted to an unused token. Consider reducing these to `contents: read` only (or removing the block entirely and relying on the org/repo default), to follow the principle of least privilege.
```suggestion
permissions:
contents: read
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: .github/workflows/draft-stale-prs.yml
Line: 20
Comment:
**Action not pinned to a commit SHA**
`actions/create-github-app-token@v2` uses a mutable major-version tag. This action handles the GitHub App's private key (`DYAD_GITHUB_APP_PRIVATE_KEY`), making it a high-value supply-chain target. A compromised or accidentally updated tag could exfiltrate secrets. Best practice is to pin to a full commit SHA, e.g.:
```suggestion
uses: actions/create-github-app-token@v2 # pin to a commit SHA, e.g. @<sha>
```
The same concern applies in `label-rebase-prs.yml` line 18.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 6ad8d49 |
| permission-contents: read | ||
| permission-pull-requests: write |
There was a problem hiding this comment.
Missing issues: write permission for label operations
The github.rest.issues.addLabels call (line 74) uses the GitHub Issues REST API (POST /repos/{owner}/{repo}/issues/{issue_number}/labels). GitHub Apps require the issues: write permission to manage labels on issues and pull requests β pull_requests: write alone is not sufficient for this endpoint.
The draft-stale-prs.yml workflow correctly requests permission-issues: write for its comment creation (issues.createComment). By analogy, this workflow also needs issues: write for label management.
Without this permission, the App token will likely receive a 403 Forbidden response when attempting to add the cc:rebase label.
| permission-contents: read | |
| permission-pull-requests: write | |
| permission-contents: read | |
| permission-pull-requests: write | |
| permission-issues: write |
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/label-rebase-prs.yml
Line: 22-23
Comment:
**Missing `issues: write` permission for label operations**
The `github.rest.issues.addLabels` call (line 74) uses the GitHub Issues REST API (`POST /repos/{owner}/{repo}/issues/{issue_number}/labels`). GitHub Apps require the `issues: write` permission to manage labels on issues and pull requests β `pull_requests: write` alone is not sufficient for this endpoint.
The `draft-stale-prs.yml` workflow correctly requests `permission-issues: write` for its comment creation (`issues.createComment`). By analogy, this workflow also needs `issues: write` for label management.
Without this permission, the App token will likely receive a `403 Forbidden` response when attempting to add the `cc:rebase` label.
```suggestion
permission-contents: read
permission-pull-requests: write
permission-issues: write
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
2 issues found across 2 files
Confidence score: 2/5
- High-confidence workflow breakage is likely:
.github/workflows/label-rebase-prs.ymllacksissues: write, sogithub.rest.issues.addLabelsshould fail when trying to label PRs. .github/workflows/draft-stale-prs.ymlhas the same permission gap (permission-issues: writemissing), which can consistently block stale/draft labeling automation via the Issues API endpoint.- Given both findings are severity 8/10 with strong confidence and affect core PR automation behavior, this carries high merge risk until permissions are corrected.
- Pay close attention to
.github/workflows/label-rebase-prs.yml,.github/workflows/draft-stale-prs.yml- missing Issues write permissions will prevent label-adding steps from working.
Prompt for AI agents (unresolved issues)
Check if these issues are valid β if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/workflows/label-rebase-prs.yml">
<violation number="1" location=".github/workflows/label-rebase-prs.yml:23">
P1: Add `issues: write` to the app token permissions; labeling a PR uses the Issues API, so `addLabels` will fail with the current token.</violation>
</file>
<file name=".github/workflows/draft-stale-prs.yml">
<violation number="1" location=".github/workflows/draft-stale-prs.yml:25">
P1: Missing `permission-issues: write` β the script calls `github.rest.issues.addLabels` which uses `POST /repos/{owner}/{repo}/issues/{issue_number}/labels`. This endpoint requires `issues: write` permission for GitHub Apps, so the `addLabels` call will fail with a 403 error. The sibling `draft-stale-prs.yml` workflow correctly includes this permission.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| app-id: ${{ vars.DYAD_GITHUB_APP_ID }} | ||
| private-key: ${{ secrets.DYAD_GITHUB_APP_PRIVATE_KEY }} | ||
| permission-contents: read | ||
| permission-pull-requests: write |
There was a problem hiding this comment.
P1: Add issues: write to the app token permissions; labeling a PR uses the Issues API, so addLabels will fail with the current token.
Prompt for AI agents
Check if this issue is valid β if so, understand the root cause and fix it. At .github/workflows/label-rebase-prs.yml, line 23:
<comment>Add `issues: write` to the app token permissions; labeling a PR uses the Issues API, so `addLabels` will fail with the current token.</comment>
<file context>
@@ -13,9 +13,18 @@ jobs:
+ app-id: ${{ vars.DYAD_GITHUB_APP_ID }}
+ private-key: ${{ secrets.DYAD_GITHUB_APP_PRIVATE_KEY }}
+ permission-contents: read
+ permission-pull-requests: write
+
- uses: actions/github-script@v7
</file context>
| permission-pull-requests: write | |
| permission-pull-requests: write | |
| permission-issues: write |
| app-id: ${{ vars.DYAD_GITHUB_APP_ID }} | ||
| private-key: ${{ secrets.DYAD_GITHUB_APP_PRIVATE_KEY }} | ||
| permission-contents: read | ||
| permission-pull-requests: write |
There was a problem hiding this comment.
P1: Missing permission-issues: write β the script calls github.rest.issues.addLabels which uses POST /repos/{owner}/{repo}/issues/{issue_number}/labels. This endpoint requires issues: write permission for GitHub Apps, so the addLabels call will fail with a 403 error. The sibling draft-stale-prs.yml workflow correctly includes this permission.
Prompt for AI agents
Check if this issue is valid β if so, understand the root cause and fix it. At .github/workflows/draft-stale-prs.yml, line 25:
<comment>Missing `permission-issues: write` β the script calls `github.rest.issues.addLabels` which uses `POST /repos/{owner}/{repo}/issues/{issue_number}/labels`. This endpoint requires `issues: write` permission for GitHub Apps, so the `addLabels` call will fail with a 403 error. The sibling `draft-stale-prs.yml` workflow correctly includes this permission.</comment>
<file context>
@@ -15,9 +15,19 @@ jobs:
+ app-id: ${{ vars.DYAD_GITHUB_APP_ID }}
+ private-key: ${{ secrets.DYAD_GITHUB_APP_PRIVATE_KEY }}
+ permission-contents: read
+ permission-pull-requests: write
+ permission-issues: write
+
</file context>
π Playwright Test Resultsβ Some tests failed
Summary: 256 passed, 2 failed, 7 flaky, 6 skipped Failed Testsπ macOS
π Re-run Failing Tests (macOS)Copy and paste to re-run all failing spec files locally: npm run e2e \
e2e-tests/select_component.spec.ts \
e2e-tests/template-create-nextjs.spec.ts
|
Summary
draft-stale-prsandlabel-rebase-prsGitHub Actions workflows from using a personal access token (PR_RW_GITHUB_TOKEN) to generating tokens via the Dyad GitHub App (actions/create-github-app-token@v2)Test plan
draft-stale-prsworkflow runs successfully on its cron schedule (or trigger manually)label-rebase-prsworkflow runs successfully when triggered by push tomaincontents: read,pull-requests: write, andissues: write(for draft-stale-prs)π€ Generated with Claude Code