Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions github/actions_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ func (s *ActionsService) ListRepoSecrets(ctx context.Context, owner, repo string
return s.listSecrets(ctx, url, opts)
}

// ListRepoOrgSecrets lists all organization secrets available in a repository
// without revealing their encrypted values.
//
// GitHub API docs: https://docs.github.com/rest/actions/secrets#list-repository-organization-secrets
//
//meta:operation GET /repos/{owner}/{repo}/actions/organization-secrets
func (s *ActionsService) ListRepoOrgSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/actions/organization-secrets", owner, repo)
return s.listSecrets(ctx, url, opts)
}

// ListOrgSecrets lists all secrets available in an organization
// without revealing their encrypted values.
//
Expand Down
43 changes: 43 additions & 0 deletions github/actions_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,49 @@ func TestActionsService_ListRepoSecrets(t *testing.T) {
})
}

func TestActionsService_ListRepoOrgSecrets(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repos/o/r/actions/organization-secrets", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"per_page": "2", "page": "2"})
fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
ctx := context.Background()
secrets, _, err := client.Actions.ListRepoOrgSecrets(ctx, "o", "r", opts)
if err != nil {
t.Errorf("Actions.ListRepoOrgSecrets returned error: %v", err)
}

want := &Secrets{
TotalCount: 4,
Secrets: []*Secret{
{Name: "A", CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
{Name: "B", CreatedAt: Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
},
}
if !cmp.Equal(secrets, want) {
t.Errorf("Actions.ListRepoOrgSecrets returned %+v, want %+v", secrets, want)
}

const methodName = "ListRepoOrgSecrets"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.ListRepoOrgSecrets(ctx, "\n", "\n", opts)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Actions.ListRepoOrgSecrets(ctx, "o", "r", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestActionsService_GetRepoSecret(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
Expand Down
10 changes: 10 additions & 0 deletions github/actions_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ func (s *ActionsService) ListRepoVariables(ctx context.Context, owner, repo stri
return s.listVariables(ctx, url, opts)
}

// ListRepoOrgVariables lists all organization variables available in a repository.
//
// GitHub API docs: https://docs.github.com/rest/actions/variables#list-repository-organization-variables
//
//meta:operation GET /repos/{owner}/{repo}/actions/organization-variables
func (s *ActionsService) ListRepoOrgVariables(ctx context.Context, owner, repo string, opts *ListOptions) (*ActionsVariables, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/actions/organization-variables", owner, repo)
return s.listVariables(ctx, url, opts)
}

// ListOrgVariables lists all variables available in an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/variables#list-organization-variables
Expand Down
43 changes: 43 additions & 0 deletions github/actions_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,49 @@ func TestActionsService_ListRepoVariables(t *testing.T) {
})
}

func TestActionsService_ListRepoOrgVariables(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repos/o/r/actions/organization-variables", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"per_page": "2", "page": "2"})
fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","value":"BB","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
ctx := context.Background()
variables, _, err := client.Actions.ListRepoOrgVariables(ctx, "o", "r", opts)
if err != nil {
t.Errorf("Actions.ListRepoOrgVariables returned error: %v", err)
}

want := &ActionsVariables{
TotalCount: 4,
Variables: []*ActionsVariable{
{Name: "A", Value: "AA", CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
{Name: "B", Value: "BB", CreatedAt: &Timestamp{time.Date(2019, time.January, 02, 15, 04, 05, 0, time.UTC)}, UpdatedAt: &Timestamp{time.Date(2020, time.January, 02, 15, 04, 05, 0, time.UTC)}},
},
}
if !cmp.Equal(variables, want) {
t.Errorf("Actions.ListRepoOrgVariables returned %+v, want %+v", variables, want)
}

const methodName = "ListRepoOrgVariables"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.ListRepoOrgVariables(ctx, "\n", "\n", opts)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Actions.ListRepoOrgVariables(ctx, "o", "r", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
return resp, err
})
}

func TestActionsService_GetRepoVariable(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
Expand Down