-
Notifications
You must be signed in to change notification settings - Fork 360
Handle PR #27837 review comments for create-project issues permissions #27868
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 all 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 |
|---|---|---|
|
|
@@ -202,3 +202,44 @@ Test workflow with update-project permissions. | |
| assert.Contains(t, stepsStr, "permission-issues: read", "GitHub App token should include issues read permission for issue-backed project items") | ||
| assert.Contains(t, stepsStr, "permission-contents: read", "GitHub App token should include contents read permission") | ||
| } | ||
|
|
||
| // TestSafeOutputsAppTokenCreateProjectWithItemURLIssuesReadPermission tests that issues read permission | ||
| // is included in the GitHub App token minting step when create-project is configured with item_url. | ||
| func TestSafeOutputsAppTokenCreateProjectWithItemURLIssuesReadPermission(t *testing.T) { | ||
| compiler := NewCompiler(WithVersion("1.0.0")) | ||
|
|
||
| markdown := `--- | ||
| on: issues | ||
| safe-outputs: | ||
| create-project: | ||
| target-owner: "my-org" | ||
| github-app: | ||
| app-id: ${{ vars.APP_ID }} | ||
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | ||
| --- | ||
|
|
||
| # Test Workflow | ||
|
|
||
| Test workflow with create-project item_url permissions. | ||
| ` | ||
|
Comment on lines
+206
to
+224
|
||
|
|
||
| tmpDir := t.TempDir() | ||
| testFile := filepath.Join(tmpDir, "test.md") | ||
| err := os.WriteFile(testFile, []byte(markdown), 0644) | ||
| require.NoError(t, err, "Failed to write test file") | ||
|
|
||
| workflowData, err := compiler.ParseWorkflowFile(testFile) | ||
| require.NoError(t, err, "Failed to parse markdown content") | ||
| require.NotNil(t, workflowData.SafeOutputs, "SafeOutputs should not be nil") | ||
| require.NotNil(t, workflowData.SafeOutputs.CreateProjects, "CreateProjects should not be nil") | ||
|
|
||
| job, _, err := compiler.buildConsolidatedSafeOutputsJob(workflowData, "main", testFile) | ||
| require.NoError(t, err, "Failed to build safe_outputs job") | ||
| require.NotNil(t, job, "Job should not be nil") | ||
|
|
||
| stepsStr := strings.Join(job.Steps, "") | ||
|
|
||
| assert.Contains(t, stepsStr, "permission-organization-projects: write", "GitHub App token should include organization projects write permission") | ||
| assert.Contains(t, stepsStr, "permission-issues: read", "GitHub App token should include issues read permission for issue-backed project items") | ||
| assert.Contains(t, stepsStr, "permission-contents: read", "GitHub App token should include contents read permission") | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,6 +202,7 @@ func ComputePermissionsForSafeOutputs(safeOutputs *SafeOutputsConfig) *Permissio | |
| if safeOutputs.CreateProjects != nil && !isHandlerStaged(safeOutputs.Staged, safeOutputs.CreateProjects.Staged) { | ||
| safeOutputsPermissionsLog.Print("Adding permissions for create-project") | ||
| permissions.Merge(NewPermissionsContentsReadProjectsWrite()) | ||
| permissions.Set(PermissionIssues, PermissionRead) | ||
|
Comment on lines
202
to
+205
|
||
| } | ||
| if safeOutputs.UpdateProjects != nil && !isHandlerStaged(safeOutputs.Staged, safeOutputs.UpdateProjects.Staged) { | ||
| safeOutputsPermissionsLog.Print("Adding permissions for update-project") | ||
|
|
||
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.
This note about
create-project+item_urlis placed under theupdate-projectsection, but thecreate-projectsection above is where users will look for create-project token requirements (especially sinceitem_urlis documented there). Consider duplicating/moving this guidance closer to thecreate-projectdocumentation so the permission requirement isn’t missed.