Skip to content

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

zyfy29
Copy link
Contributor

@zyfy29 zyfy29 commented Aug 15, 2025

3rd Pull Request for #3660

Add support for the "Allowing workflows on fork pull requests in private repositories" APIs, covering 6 endpoints.

@Copilot Copilot AI review requested due to automatic review settings August 15, 2025 07:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds API support for managing private repository fork PR workflow permissions across repositories, organizations, and enterprises. It implements 6 new endpoints for getting and setting workflow permissions that control how fork pull requests can run workflows on private repositories.

  • Adds WorkflowsPermissions struct to represent fork PR workflow settings
  • Implements repository-level API methods for getting and setting private repo fork PR workflow settings
  • Implements organization-level and enterprise-level API methods for the same functionality

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
github/actions_workflows.go Adds WorkflowsPermissions struct with four boolean fields for controlling fork PR workflow behavior
github/repos_actions_permissions.go Implements repository-level GET and PUT methods for private repo fork PR workflow settings
github/actions_permissions_orgs.go Implements organization-level GET and PUT methods for private repo fork PR workflow settings
github/actions_permissions_enterprise.go Implements enterprise-level GET and PUT methods for private repo fork PR workflow settings
github/repos_actions_permissions_test.go Adds comprehensive tests for the repository-level API methods
github/actions_permissions_orgs_test.go Adds comprehensive tests for the organization-level API methods
github/actions_permissions_enterprise_test.go Adds comprehensive tests for the enterprise-level API methods
github/github-accessors.go Adds getter methods for the WorkflowsPermissions struct fields
github/github-accessors_test.go Adds tests for the getter methods
github/github-stringify_test.go Adds test for the String() method of WorkflowsPermissions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.10%. Comparing base (69dc04b) to head (a864e95).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3679      +/-   ##
==========================================
+ Coverage   91.07%   91.10%   +0.03%     
==========================================
  Files         186      186              
  Lines       16563    16625      +62     
==========================================
+ Hits        15085    15147      +62     
  Misses       1293     1293              
  Partials      185      185              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Aug 15, 2025
Copy link
Contributor

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @zyfy29!
LGTM.

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

@alexandear or @stevehipwell - might you have time for a code review? Thank you!

// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#set-private-repo-fork-pr-workflow-settings-for-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/fork-pr-workflows-private-repos
func (s *ActionsService) EditPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx context.Context, enterprise string, permissions WorkflowsPermissions) (*Response, error) {
Copy link
Contributor

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_requests is required. So, we can't reuse WorkflowsPermissions here because RunWorkflowsFromForkPullRequests has a pointer type *bool.

Copy link
Contributor Author

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!

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"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
RequireApprovalForForkPrWorkflows *bool `json:"require_approval_for_fork_pr_workflows,omitempty"`
RequireApprovalForForkPRWorkflows *bool `json:"require_approval_for_fork_pr_workflows,omitempty"`

@zyfy29 zyfy29 requested a review from alexandear August 15, 2025 22:31
Copy link
Contributor

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/permissions#set-private-repo-fork-pr-workflow-settings-for-an-enterprise
//
//meta:operation PUT /enterprises/{enterprise}/actions/permissions/fork-pr-workflows-private-repos
func (s *ActionsService) EditPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx context.Context, enterprise string, permissions *WorkflowsPermissionsOpt) (*Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (s *ActionsService) EditPrivateRepoForkPRWorkflowSettingsInEnterprise(ctx context.Context, enterprise string, permissions *WorkflowsPermissionsOpt) (*Response, error) {
func (s *ActionsService) UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise(ctx context.Context, enterprise string, permissions *WorkflowsPermissionsOpt) (*Response, error) {

I think update makes more sense than edit both here and in the wider context of the package API.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you are right, @stevehipwell, thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's OK, I'll rename it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or may I open another pr to do that? For the permissons APIs above, methods have been named GetXXX and EditXXX where both GET and PUT methods are used for the same path. I think we better rename it all at once to keep consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I renamed the methods implemented in this pr for now.

@zyfy29 zyfy29 requested a review from stevehipwell August 19, 2025 05:10
Copy link
Contributor

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

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

LGTM

})
}

func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) {
func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInOrganization(t *testing.T) {

Copy link
Contributor Author

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!

})
}

func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func TestActionsService_EditPrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) {
func TestActionsService_UpdatePrivateRepoForkPRWorkflowSettingsInEnterprise(t *testing.T) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsReview PR is awaiting a review before merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants