-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: Support OIDC custom property claims for Actions #4411
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
base: master
Are you sure you want to change the base?
Changes from all commits
932a0ee
23e3022
aee056e
c45355e
24e49a4
477db18
274c01d
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 |
|---|---|---|
|
|
@@ -81,3 +81,121 @@ func (s *ActionsService) setOIDCSubjectClaimCustomTemplate(ctx context.Context, | |
|
|
||
| return s.client.Do(req, nil) | ||
| } | ||
|
|
||
| // InclusionSource represents whether the custom oidc property claim was defined at the organization or enterprise level. | ||
| type InclusionSource string | ||
|
|
||
| // InclusionSource constants represent whether the inclusion was defined at the organization or enterprise level. | ||
| const ( | ||
| InclusionSourceEnterprise InclusionSource = "enterprise" | ||
| InclusionSourceOrganization InclusionSource = "organization" | ||
| ) | ||
|
|
||
| // OIDCCustomPropertyClaim represents an OIDC custom property claim for GitHub Actions. | ||
| type OIDCCustomPropertyClaim struct { | ||
| CustomPropertyName string `json:"custom_property_name"` | ||
| } | ||
|
|
||
| // OIDCCustomPropertyClaimResponse represents the OIDC custom property claim along with the inclusion source (enterprise or organization) for GitHub Actions. | ||
| type OIDCCustomPropertyClaimResponse struct { | ||
| OIDCCustomPropertyClaim | ||
| InclusionSource InclusionSource `json:"inclusion_source"` | ||
| } | ||
|
|
||
| // ListEnterpriseOIDCCustomPropertyClaims lists the custom property claims in oidc for enterprise actions. | ||
| // | ||
| // GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#list-oidc-custom-property-inclusions-for-an-enterprise | ||
| // | ||
| //meta:operation GET /enterprises/{enterprise}/actions/oidc/customization/properties/repo | ||
| func (s *ActionsService) ListEnterpriseOIDCCustomPropertyClaims(ctx context.Context, enterprise string) ([]*OIDCCustomPropertyClaimResponse, *Response, error) { | ||
| u := fmt.Sprintf("enterprises/%v/actions/oidc/customization/properties/repo", enterprise) | ||
| return s.listOIDCCustomPropertyClaims(ctx, u) | ||
| } | ||
|
|
||
| // ListOrgOIDCCustomPropertyClaims lists the custom property claims in oidc for organization actions. | ||
| // | ||
| // GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#list-oidc-custom-property-inclusions-for-an-organization | ||
| // | ||
| //meta:operation GET /orgs/{org}/actions/oidc/customization/properties/repo | ||
| func (s *ActionsService) ListOrgOIDCCustomPropertyClaims(ctx context.Context, org string) ([]*OIDCCustomPropertyClaimResponse, *Response, error) { | ||
| u := fmt.Sprintf("orgs/%v/actions/oidc/customization/properties/repo", org) | ||
| return s.listOIDCCustomPropertyClaims(ctx, u) | ||
| } | ||
|
|
||
| func (s *ActionsService) listOIDCCustomPropertyClaims(ctx context.Context, url string) ([]*OIDCCustomPropertyClaimResponse, *Response, error) { | ||
| req, err := s.client.NewRequest(ctx, "GET", url, nil) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
|
|
||
| var props []*OIDCCustomPropertyClaimResponse | ||
| resp, err := s.client.Do(req, &props) | ||
| if err != nil { | ||
| return nil, resp, err | ||
| } | ||
|
|
||
| return props, resp, nil | ||
| } | ||
|
|
||
| // SetEnterpriseOIDCCustomPropertyClaim sets a new custom property claim in oidc for enterprise actions. | ||
| // | ||
| // GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#create-an-oidc-custom-property-inclusion-for-an-enterprise | ||
| // | ||
| //meta:operation POST /enterprises/{enterprise}/actions/oidc/customization/properties/repo | ||
| func (s *ActionsService) SetEnterpriseOIDCCustomPropertyClaim(ctx context.Context, enterprise string, body OIDCCustomPropertyClaim) (*OIDCCustomPropertyClaim, *Response, error) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah right. just added a new type |
||
| u := fmt.Sprintf("enterprises/%v/actions/oidc/customization/properties/repo", enterprise) | ||
| return s.setOIDCCustomPropertyClaim(ctx, u, body) | ||
| } | ||
|
|
||
| // SetOrgOIDCCustomPropertyClaim sets a new custom property claim in oidc for organization actions. | ||
| // | ||
| // GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#create-an-oidc-custom-property-inclusion-for-an-organization | ||
| // | ||
| //meta:operation POST /orgs/{org}/actions/oidc/customization/properties/repo | ||
| func (s *ActionsService) SetOrgOIDCCustomPropertyClaim(ctx context.Context, org string, body OIDCCustomPropertyClaim) (*OIDCCustomPropertyClaim, *Response, error) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ended up making |
||
| u := fmt.Sprintf("orgs/%v/actions/oidc/customization/properties/repo", org) | ||
| return s.setOIDCCustomPropertyClaim(ctx, u, body) | ||
| } | ||
|
|
||
| func (s *ActionsService) setOIDCCustomPropertyClaim(ctx context.Context, url string, body OIDCCustomPropertyClaim) (*OIDCCustomPropertyClaim, *Response, error) { | ||
| req, err := s.client.NewRequest(ctx, "POST", url, body) | ||
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
|
|
||
| var customProperty *OIDCCustomPropertyClaim | ||
| resp, err := s.client.Do(req, &customProperty) | ||
| if err != nil { | ||
| return nil, resp, err | ||
| } | ||
| return customProperty, resp, err | ||
| } | ||
|
|
||
| // DeleteEnterpriseOIDCCustomPropertyClaim deletes a custom property claim in oidc for enterprise actions. | ||
| // | ||
| // GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#delete-an-oidc-custom-property-inclusion-for-an-enterprise | ||
| // | ||
| //meta:operation DELETE /enterprises/{enterprise}/actions/oidc/customization/properties/repo/{custom_property_name} | ||
| func (s *ActionsService) DeleteEnterpriseOIDCCustomPropertyClaim(ctx context.Context, enterprise, customProperty string) (*Response, error) { | ||
| u := fmt.Sprintf("enterprises/%v/actions/oidc/customization/properties/repo/%v", enterprise, customProperty) | ||
| return s.deleteOIDCCustomPropertyClaim(ctx, u) | ||
| } | ||
|
|
||
| // DeleteOrgOIDCCustomPropertyClaim deletes a custom property claim in oidc for organization actions. | ||
| // | ||
| // GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#delete-an-oidc-custom-property-inclusion-for-an-organization | ||
| // | ||
| //meta:operation DELETE /orgs/{org}/actions/oidc/customization/properties/repo/{custom_property_name} | ||
| func (s *ActionsService) DeleteOrgOIDCCustomPropertyClaim(ctx context.Context, enterprise, customProperty string) (*Response, error) { | ||
| u := fmt.Sprintf("orgs/%v/actions/oidc/customization/properties/repo/%v", enterprise, customProperty) | ||
| return s.deleteOIDCCustomPropertyClaim(ctx, u) | ||
| } | ||
|
|
||
| func (s *ActionsService) deleteOIDCCustomPropertyClaim(ctx context.Context, url string) (*Response, error) { | ||
| req, err := s.client.NewRequest(ctx, "DELETE", url, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return s.client.Do(req, nil) | ||
| } | ||
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.

Uh oh!
There was an error while loading. Please reload this page.