Skip to content

feat: Add actions policies endpoints - #4604

Open
Bobrovskii wants to merge 2 commits into
google:masterfrom
Bobrovskii:feat/actions-policies-endpoints
Open

Bobrovskii wants to merge 2 commits into
google:masterfrom
Bobrovskii:feat/actions-policies-endpoints

Conversation

@Bobrovskii

Copy link
Copy Markdown
Contributor

Add actions policies endpoints
Fixes: #4583

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Oct 2, 2026
@codecov

codecov Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.61%. Comparing base (9a9d77c) to head (9076c75).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4604      +/-   ##
==========================================
+ Coverage   98.60%   98.61%   +0.01%     
==========================================
  Files         198      199       +1     
  Lines       18538    18647     +109     
==========================================
+ Hits        18279    18389     +110     
+ Misses        259      258       -1     

☔ View full report in Codecov by Harness.
📢 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 commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

@Bobrovskii - please fix the linter errors by running ./script/lint.sh locally and fixing all issues found, then push the changes to this PR. See step 4 in CONTRIBUTING.md for more information.

@Bobrovskii

Copy link
Copy Markdown
Contributor Author

Fixed the linter issues and the missing test coverage. Thanks

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @Bobrovskii!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @Not-Dhananjay-Mishra

return policies, resp, nil
}

func (s *ActionsService) createPolicy(ctx context.Context, u string, body ActionsPolicy) (*ActionsPolicy, *Response, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ActionsPolicy contains some extra fields that aren't needed when creating a policy. Can we introduce a new request struct for this?

return policy, resp, nil
}

func (s *ActionsService) updatePolicy(ctx context.Context, u string, body ActionsPolicy) (*ActionsPolicy, *Response, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here, some extra fields that aren't needed when updating a policy.

Comment on lines +46 to +59
type ActionsPolicy struct {
ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Target *ActionsPolicyTarget `json:"target,omitempty"`
SourceType *RulesetSourceType `json:"source_type,omitempty"`
Source *string `json:"source,omitempty"`
Enforcement *RulesetEnforcement `json:"enforcement,omitempty"`
Conditions *ActionsPolicyConditions `json:"conditions,omitempty"`
Rules []*ActionsPolicyRule `json:"rules,omitzero"`
NodeID *string `json:"node_id,omitempty"`
Links *RepositoryRulesetLinks `json:"_links,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
type ActionsPolicy struct {
ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Target *ActionsPolicyTarget `json:"target,omitempty"`
SourceType *RulesetSourceType `json:"source_type,omitempty"`
Source *string `json:"source,omitempty"`
Enforcement *RulesetEnforcement `json:"enforcement,omitempty"`
Conditions *ActionsPolicyConditions `json:"conditions,omitempty"`
Rules []*ActionsPolicyRule `json:"rules,omitzero"`
NodeID *string `json:"node_id,omitempty"`
Links *RepositoryRulesetLinks `json:"_links,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
}
type ActionsPolicy struct {
ID int64 `json:"id"`
Name string `json:"name"`
Target ActionsPolicyTarget `json:"target"`
SourceType RulesetSourceType `json:"source_type"`
Source string `json:"source"`
Enforcement RulesetEnforcement `json:"enforcement"`
Conditions *ActionsPolicyConditions `json:"conditions,omitempty"`
Rules []*ActionsPolicyRule `json:"rules,omitzero"`
NodeID *string `json:"node_id,omitempty"`
Links *RepositoryRulesetLinks `json:"_links,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
}

We don't use omitempty with required fields.

  "required": [
    "id",
    "name",
    "target",
    "source_type",
    "source",
    "enforcement"
  ],

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.

Add actions policies endpoints

3 participants