Skip to content

feat!: Replace actions env secret endpoints#4335

Open
stevehipwell wants to merge 4 commits into
google:masterfrom
stevehipwell:actions-repo-env-secrets
Open

feat!: Replace actions env secret endpoints#4335
stevehipwell wants to merge 4 commits into
google:masterfrom
stevehipwell:actions-repo-env-secrets

Conversation

@stevehipwell

Copy link
Copy Markdown
Contributor

This PR updates the actions environment secrets functions to use the documented and supported endpoints, it also changes all actions secret create/update functions to use a value parameter (#3644).

Signed-off-by: Steve Hipwell <steve.hipwell@gmail.com>
@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Jun 26, 2026
Comment thread example/newreposecretwithxcrypto/main.go Outdated
Comment thread github/actions_secrets.go
Comment on lines +250 to +251
if body.Name == "" {
return nil, errors.New("secret name must be provided")

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.

We usually don't add such checks to other endpoint methods.

The field Name is without omitempty, which means "required".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's used to construct the URL, which is why I think the previous signature had nil checks (although an uninitialized struct would still cause issues).

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.

Now I understand. In that way, we should add a new parameter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A new parameter or a new request type (as per below)?

@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.50%. Comparing base (c9f5330) to head (2c8137a).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4335      +/-   ##
==========================================
+ Coverage   97.48%   97.50%   +0.01%     
==========================================
  Files         193      193              
  Lines       19417    19451      +34     
==========================================
+ Hits        18929    18965      +36     
+ Misses        270      269       -1     
+ Partials      218      217       -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.

Comment thread github/actions_secrets.go
func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, body *EncryptedSecret) (*Response, error) {
if body == nil {
return nil, errors.New("encrypted secret must be provided")
func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, body EncryptedSecret) (*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.

Suggested change
func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, body EncryptedSecret) (*Response, error) {
func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo, secretName string, body CreateOrUpdateRepoSecretRequest) (*Response, error) {
type CreateOrUpdateRepoSecretRequest struct {
	KeyID                 string          `json:"key_id"`
	EncryptedValue        string          `json:"encrypted_value"`
}

Because https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret

Image

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.

The similar for other endpoints

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'd considered doing this but didn't want to shave the yak, but I think that boat has sailed now. How about SecretRequest (for repo and env) and OrgSecretRequest; I'd like to think that this endpoint will eventually be replaced with separate endpoints for create and update. The Dependabot endpoints could use the same types, although I'm not sure we want to make that change in this PR?

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.

Currently, these ActionsService endpoints are completely broken. We can fix them whenever needed. And adding new structs won't break Dependabot endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants