github.com/google/go-github/v49@v49.1.0/github/repos_actions_allowed.go (about) 1 // Copyright 2022 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "context" 10 "fmt" 11 ) 12 13 // GetActionsAllowed gets the allowed actions and reusable workflows for a repository. 14 // 15 // GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-a-repository 16 func (s *RepositoriesService) GetActionsAllowed(ctx context.Context, org, repo string) (*ActionsAllowed, *Response, error) { 17 u := fmt.Sprintf("repos/%v/%v/actions/permissions/selected-actions", org, repo) 18 req, err := s.client.NewRequest("GET", u, nil) 19 if err != nil { 20 return nil, nil, err 21 } 22 23 actionsAllowed := new(ActionsAllowed) 24 resp, err := s.client.Do(ctx, req, actionsAllowed) 25 if err != nil { 26 return nil, resp, err 27 } 28 29 return actionsAllowed, resp, nil 30 } 31 32 // EditActionsAllowed sets the allowed actions and reusable workflows for a repository. 33 // 34 // GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-a-repository 35 func (s *RepositoriesService) EditActionsAllowed(ctx context.Context, org, repo string, actionsAllowed ActionsAllowed) (*ActionsAllowed, *Response, error) { 36 u := fmt.Sprintf("repos/%v/%v/actions/permissions/selected-actions", org, repo) 37 req, err := s.client.NewRequest("PUT", u, actionsAllowed) 38 if err != nil { 39 return nil, nil, err 40 } 41 42 p := new(ActionsAllowed) 43 resp, err := s.client.Do(ctx, req, p) 44 if err != nil { 45 return nil, resp, err 46 } 47 48 return p, resp, nil 49 }