-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: Add private repo workflows permission API support #3679
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 5 commits
155da37
8ec23fb
7e85478
053462c
a864e95
af079dc
9e8e913
0c11edd
c4d4fea
160ae72
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -523,3 +523,85 @@ func TestActionsService_EditSelfHostedRunnerPermissionsInEnterprise(t *testing.T | |||||
| return client.Actions.EditSelfHostedRunnerPermissionsInEnterprise(ctx, "e", *input) | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| func TestActionsService_GetPrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) { | ||||||
| t.Parallel() | ||||||
| client, mux, _ := setup(t) | ||||||
|
|
||||||
| mux.HandleFunc("/enterprises/e/actions/permissions/fork-pr-workflows-private-repos", func(w http.ResponseWriter, r *http.Request) { | ||||||
| testMethod(t, r, "GET") | ||||||
| fmt.Fprint(w, `{"run_workflows_from_fork_pull_requests": true, "send_write_tokens_to_workflows": false, "send_secrets_and_variables": true, "require_approval_for_fork_pr_workflows": false}`) | ||||||
| }) | ||||||
|
|
||||||
| ctx := context.Background() | ||||||
| permissions, _, err := client.Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx, "e") | ||||||
| if err != nil { | ||||||
| t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise returned error: %v", err) | ||||||
| } | ||||||
| want := &WorkflowsPermissions{ | ||||||
| RunWorkflowsFromForkPullRequests: Ptr(true), | ||||||
| SendWriteTokensToWorkflows: Ptr(false), | ||||||
| SendSecretsAndVariables: Ptr(true), | ||||||
| RequireApprovalForForkPrWorkflows: Ptr(false), | ||||||
| } | ||||||
| if !cmp.Equal(permissions, want) { | ||||||
| t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise returned %+v, want %+v", permissions, want) | ||||||
| } | ||||||
|
|
||||||
| const methodName = "GetPrivateRepoForkPRWorkflowSettingsInEnterprise" | ||||||
| testBadOptions(t, methodName, func() (err error) { | ||||||
| _, _, err = client.Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx, "\n") | ||||||
| return err | ||||||
| }) | ||||||
|
|
||||||
| testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { | ||||||
| got, resp, err := client.Actions.GetPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx, "e") | ||||||
| if got != nil { | ||||||
| t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) | ||||||
| } | ||||||
| return resp, err | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) { | ||||||
|
||||||
| func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) { | |
| func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) { |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -693,3 +693,85 @@ func TestActionsService_RemoveRepositorySelfHostedRunnersAllowedInOrganization(t | |||||
| return client.Actions.RemoveRepositorySelfHostedRunnersAllowedInOrganization(ctx, "o", 123) | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| func TestActionsService_GetPrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) { | ||||||
| t.Parallel() | ||||||
| client, mux, _ := setup(t) | ||||||
|
|
||||||
| mux.HandleFunc("/orgs/o/actions/permissions/fork-pr-workflows-private-repos", func(w http.ResponseWriter, r *http.Request) { | ||||||
| testMethod(t, r, "GET") | ||||||
| fmt.Fprint(w, `{"run_workflows_from_fork_pull_requests": true, "send_write_tokens_to_workflows": false, "send_secrets_and_variables": true, "require_approval_for_fork_pr_workflows": false}`) | ||||||
| }) | ||||||
|
|
||||||
| ctx := context.Background() | ||||||
| permissions, _, err := client.Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization(ctx, "o") | ||||||
| if err != nil { | ||||||
| t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization returned error: %v", err) | ||||||
| } | ||||||
| want := &WorkflowsPermissions{ | ||||||
| RunWorkflowsFromForkPullRequests: Ptr(true), | ||||||
| SendWriteTokensToWorkflows: Ptr(false), | ||||||
| SendSecretsAndVariables: Ptr(true), | ||||||
| RequireApprovalForForkPrWorkflows: Ptr(false), | ||||||
| } | ||||||
| if !cmp.Equal(permissions, want) { | ||||||
| t.Errorf("Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization returned %+v, want %+v", permissions, want) | ||||||
| } | ||||||
|
|
||||||
| const methodName = "GetPrivateRepoForkPRWorkflowSettingsInOrganization" | ||||||
| testBadOptions(t, methodName, func() (err error) { | ||||||
| _, _, err = client.Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization(ctx, "\n") | ||||||
| return err | ||||||
| }) | ||||||
|
|
||||||
| testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { | ||||||
| got, resp, err := client.Actions.GetPrivateRepoForkPRWorkflowSettingsInOrganization(ctx, "o") | ||||||
| if got != nil { | ||||||
| t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) | ||||||
| } | ||||||
| return resp, err | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) { | ||||||
|
||||||
| func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) { | |
| func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) { |
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.
Oh, I fix it. Thank you!
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -56,6 +56,18 @@ type CreateWorkflowDispatchEventRequest struct { | |||||||
| Inputs map[string]any `json:"inputs,omitempty"` | ||||||||
| } | ||||||||
|
|
||||||||
| // WorkflowsPermissions represents the permissions for workflows in a repository. | ||||||||
| type WorkflowsPermissions struct { | ||||||||
| RunWorkflowsFromForkPullRequests *bool `json:"run_workflows_from_fork_pull_requests,omitempty"` | ||||||||
| SendWriteTokensToWorkflows *bool `json:"send_write_tokens_to_workflows,omitempty"` | ||||||||
| SendSecretsAndVariables *bool `json:"send_secrets_and_variables,omitempty"` | ||||||||
| RequireApprovalForForkPrWorkflows *bool `json:"require_approval_for_fork_pr_workflows,omitempty"` | ||||||||
|
||||||||
| RequireApprovalForForkPrWorkflows *bool `json:"require_approval_for_fork_pr_workflows,omitempty"` | |
| RequireApprovalForForkPRWorkflows *bool `json:"require_approval_for_fork_pr_workflows,omitempty"` | |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
According to the doc, the body parameter
run_workflows_from_fork_pull_requestsis required. So, we can't reuseWorkflowsPermissionshere becauseRunWorkflowsFromForkPullRequestshas a pointer type*bool.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.
Now I use a mixture of pointer and non-pointer fileds to address that. Thanks for your review!