├── actionutil ├── actionutil.go ├── github.go ├── git.go └── githubapi.go ├── Dockerfile ├── cmd └── goaction │ ├── main_test.go │ └── main.go ├── .github ├── tests │ ├── README.md │ ├── test-env-set │ │ └── main.go │ ├── test-input │ │ └── main.go │ └── prepare │ │ └── main.go └── workflows │ ├── goreadme.yml │ ├── testgo.yml │ ├── testevents.yml │ ├── goaction.yml │ └── testworkflow.yml ├── go.mod ├── internal ├── genevents │ ├── event_test.go.gotmpl │ ├── event.go.gotmpl │ └── main.go ├── comments │ └── comments.go ├── genapi │ ├── githubapi.go.gotmpl │ └── main.go └── metadata │ ├── metadata_test.go │ └── metadata.go ├── goaction_test.go ├── action.yml ├── log ├── log_test.go └── log.go ├── README.md ├── event_test.go ├── go.sum ├── event.go ├── goaction.go └── LICENSE /actionutil/actionutil.go: -------------------------------------------------------------------------------- 1 | // Package actionutil provides utility functions for Github actions. 2 | package actionutil 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # File generated by github.com/posener/goaction. DO NOT EDIT. 2 | 3 | 4 | FROM golang:1.14.2-alpine3.11 5 | RUN apk add git 6 | 7 | COPY . /home/src 8 | WORKDIR /home/src 9 | RUN go build -o /bin/action ./cmd/goaction 10 | 11 | ENTRYPOINT [ "/bin/action" ] 12 | -------------------------------------------------------------------------------- /cmd/goaction/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func TestPathRelDir(t *testing.T) { 11 | t.Parallel() 12 | 13 | tests := []struct{ path, want string }{ 14 | {"", "./"}, 15 | {"./", "./"}, 16 | {"src/", "./src"}, 17 | {"./src/", "./src"}, 18 | } 19 | 20 | for _, tt := range tests { 21 | got, err := pathRelDir(tt.path) 22 | require.NoError(t, err) 23 | assert.Equal(t, tt.want, got) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /.github/tests/README.md: -------------------------------------------------------------------------------- 1 | # Workflow communication test jobs 2 | 3 | The workflow defined at /.github/workflows/testworkflow.yml runs the jobs defined in this directory. 4 | For each one of them, it runs goaction to update to Action file in the project root directory: 5 | `goaction -path ./.github/tests/`. This overrides the `Dockerfile` and 6 | `action.yml` files which are then invoked by an action with `uses: ./`. 7 | 8 | The idea is to test communication between two actions. Things that were set in one job or step are 9 | correctly read in another job or step. -------------------------------------------------------------------------------- /.github/workflows/goreadme.yml: -------------------------------------------------------------------------------- 1 | on: 2 | pull_request: 3 | branches: [master] 4 | push: 5 | branches: [master] 6 | permissions: 7 | # Goreadme needs permissions to update pull requests comments and update contents. 8 | pull-requests: write 9 | contents: write 10 | jobs: 11 | goreadme: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Check out repository 15 | uses: actions/checkout@v2 16 | - name: Update readme according to Go doc 17 | uses: posener/goreadme@v1 18 | with: 19 | badge-godoc: true 20 | GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' 21 | -------------------------------------------------------------------------------- /.github/tests/test-env-set/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | 7 | "github.com/posener/goaction/log" 8 | ) 9 | 10 | var fail = false 11 | 12 | func main() { 13 | flag.Parse() 14 | 15 | if got, want := os.Getenv("set"), "set"; got != want { 16 | errorf(`os.Getenv("set") = %s, want %s`, got, want) 17 | } 18 | 19 | if got, want := os.Getenv("export"), "export"; got != want { 20 | errorf(`os.Getenv("export") = %s, want %s`, got, want) 21 | } 22 | 23 | if fail { 24 | log.Fatalf("Failed...") 25 | } 26 | } 27 | 28 | func errorf(f string, args ...interface{}) { 29 | log.Printf(f, args...) 30 | fail = true 31 | } 32 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/posener/goaction 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/davecgh/go-spew v1.1.1 // indirect 7 | github.com/goccy/go-yaml v1.4.3 8 | github.com/google/go-github/v31 v31.0.0 9 | github.com/hashicorp/go-multierror v1.1.0 // indirect 10 | github.com/kr/pretty v0.2.0 // indirect 11 | github.com/posener/autogen v0.0.2 12 | github.com/posener/script v1.1.5 13 | github.com/stretchr/testify v1.5.1 14 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d 15 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e 16 | google.golang.org/appengine v1.6.5 // indirect 17 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect 18 | ) 19 | -------------------------------------------------------------------------------- /internal/genevents/event_test.go.gotmpl: -------------------------------------------------------------------------------- 1 | package goaction 2 | // Code auto generated with `go run ./internal/genevents/main.go`. DO NOT EDIT 3 | 4 | import ( 5 | "testing" 6 | 7 | "github.com/stretchr/testify/assert" 8 | ) 9 | 10 | {{ range . }} 11 | {{ if not .SkipEventGetFunc }} 12 | func Test{{ .EventGetFuncName }}(t *testing.T) { 13 | if Event != Event{{ .CamelCase }} { 14 | t.Skipf("Only applicatble for '{{ .Pretty }}'") 15 | } 16 | event, err := {{ .EventGetFuncName }}() 17 | assert.NoError(t, err) 18 | 19 | var out bytes.Buffer 20 | err = json.NewEncoder(&out).Encode(event) 21 | require.NoError(t, err) 22 | t.Log(out.String()) 23 | } 24 | {{ end }} 25 | {{ end }} -------------------------------------------------------------------------------- /.github/workflows/testgo.yml: -------------------------------------------------------------------------------- 1 | on: 2 | pull_request: 3 | branches: [master] 4 | push: 5 | branches: [master] 6 | jobs: 7 | test: 8 | strategy: 9 | matrix: 10 | go-version: 11 | - 1.13.x 12 | - 1.14.x 13 | platform: 14 | - ubuntu-latest 15 | runs-on: ${{ matrix.platform }} 16 | steps: 17 | - name: Install Go 18 | uses: actions/setup-go@v1 19 | with: 20 | go-version: ${{ matrix.go-version }} 21 | - name: Checkout code 22 | uses: actions/checkout@v2 23 | - name: Test 24 | run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... 25 | - name: Report coverage 26 | uses: codecov/codecov-action@v1 27 | with: 28 | file: coverage.txt 29 | fail_ci_if_error: true -------------------------------------------------------------------------------- /goaction_test.go: -------------------------------------------------------------------------------- 1 | package goaction 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | func TestVars(t *testing.T) { 9 | if !CI { 10 | t.Skip("Only runs in CI mode") 11 | } 12 | 13 | assert.Equal(t, "/home/runner", Home) 14 | assert.Equal(t, ".github/workflows/testgo.yml", Workflow) 15 | assert.Equal(t, "posener/goaction", Repository) 16 | assert.NotEmpty(t, RunID) 17 | assert.NotEmpty(t, RunNum) 18 | assert.NotEmpty(t, ActionID) 19 | assert.NotEmpty(t, Actor) 20 | assert.NotEmpty(t, Workspace) 21 | assert.NotEmpty(t, SHA) 22 | assert.NotEmpty(t, Ref) 23 | 24 | assert.Equal(t, "posener", Owner()) 25 | assert.Equal(t, "goaction", Project()) 26 | switch Event{ 27 | case EventPush: 28 | assert.Equal(t, "master", Branch()) 29 | case EventPullRequest: 30 | assert.Less(t, 0, PrNum()) 31 | } 32 | } -------------------------------------------------------------------------------- /.github/workflows/testevents.yml: -------------------------------------------------------------------------------- 1 | # Tests parsing of event json objects in different Github events. 2 | on: 3 | - check_run 4 | - check_suite 5 | - create 6 | - delete 7 | - deployment 8 | - fork 9 | - gollum 10 | - issue_comment 11 | - issues 12 | - label 13 | - milestone 14 | - page_build 15 | - project 16 | - project_card 17 | - public 18 | - pull_request 19 | - pull_request_review 20 | - pull_request_review_comment 21 | - push 22 | - registry_package 23 | - release 24 | - status 25 | - watch 26 | - schedule 27 | - repository_dispatch 28 | jobs: 29 | test: 30 | runs-on: ubuntu-latest 31 | steps: 32 | - name: Install Go 33 | uses: actions/setup-go@v1 34 | with: 35 | go-version: 1.14.x 36 | - name: Checkout code 37 | uses: actions/checkout@v2 38 | - name: Test 39 | run: go test -run "^TestGet" -v 40 | -------------------------------------------------------------------------------- /.github/tests/test-input/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | 7 | "github.com/posener/goaction/log" 8 | ) 9 | 10 | var ( 11 | message = flag.String("message", "", "Input from first job.") 12 | arg = flag.Int("arg", 0, "Int value.") 13 | 14 | fail = false 15 | ) 16 | 17 | func main() { 18 | flag.Parse() 19 | 20 | // Tests that input from first job passed correctly. 21 | 22 | if got, want := *message, "message"; got != want { 23 | errorf(`flag.String("message") = %s, want %s`, got, want) 24 | } 25 | 26 | if got, want := *arg, 42; got != want { 27 | errorf(`flag.Int("arg") = %d, want %d`, got, want) 28 | } 29 | 30 | // Test that the environment variable is not set with standard name: 31 | if got, want := os.Getenv("env"), "env"; got != want { 32 | errorf(`os.Getenv("env") = %s, want %s`, got, want) 33 | } 34 | 35 | if fail { 36 | log.Fatalf("Failed...") 37 | } 38 | } 39 | 40 | func errorf(f string, args ...interface{}) { 41 | log.Printf(f, args...) 42 | fail = true 43 | } 44 | -------------------------------------------------------------------------------- /internal/genevents/event.go.gotmpl: -------------------------------------------------------------------------------- 1 | package goaction 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/google/go-github/v31/github" 9 | ) 10 | 11 | // A Github action triggering event. 12 | // See https://help.github.com/en/actions/reference/events-that-trigger-workflows. 13 | type EventType string 14 | 15 | // All Github action event types. 16 | const ( 17 | {{ range . }} Event{{ .CamelCase }} EventType = "{{ .Name }}" 18 | {{ end }} 19 | ) 20 | {{ range . }} 21 | {{ if not .SkipEventGetFunc }} 22 | // {{ .EventGetFuncName }} returns information about a current {{ .Pretty }}. 23 | func {{ .EventGetFuncName }}() (*{{ .GithubReturnValue }}, error) { 24 | if Event != Event{{ .CamelCase }} { 25 | return nil, fmt.Errorf("not '{{ .Name }}' event") 26 | } 27 | var i {{ .GithubReturnValue }} 28 | err := decodeEventInfo(&i) 29 | return &i, err 30 | } 31 | {{ end }} 32 | {{ end }} 33 | 34 | func decodeEventInfo(i interface{}) error { 35 | f, err := os.Open(eventPath) 36 | if err != nil { 37 | return err 38 | } 39 | defer f.Close() 40 | return json.NewDecoder(f).Decode(i) 41 | } -------------------------------------------------------------------------------- /.github/workflows/goaction.yml: -------------------------------------------------------------------------------- 1 | on: 2 | pull_request: 3 | branches: [master] 4 | push: 5 | branches: [master] 6 | permissions: 7 | # Goaction needs permissions to update pull requests comments and update contents. 8 | pull-requests: write 9 | contents: write 10 | jobs: 11 | goaction: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Check out repository 15 | uses: actions/checkout@v2 16 | # Inception: install goaction from current code and 17 | # update the action files. 18 | - name: Install Go 19 | uses: actions/setup-go@v1 20 | with: 21 | go-version: 1.14.x 22 | - name: Generate new Action files using new code. 23 | # Set CI=false to skip the CI flow of goaction. 24 | env: 25 | CI: false 26 | run: go run ./cmd/goaction -path ./cmd/goaction 27 | # Action files updated... 28 | # Contine goaction with the normal flow. 29 | - name: Update action files 30 | uses: ./ 31 | with: 32 | name: posener/goaction 33 | description: Github actions for Go code 34 | path: cmd/goaction 35 | GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' 36 | icon: activity 37 | color: blue 38 | -------------------------------------------------------------------------------- /.github/tests/prepare/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/posener/goaction" 7 | "github.com/posener/goaction/log" 8 | ) 9 | 10 | var fail = false 11 | 12 | func main() { 13 | // Write an output for the second action. 14 | goaction.Output("out", "message", "output of first action") 15 | // Set an environment variable for the second action. 16 | err := goaction.Setenv("set", "set") 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | // Set an environment variable for the second action using export. 21 | err = goaction.Export("export", "export") 22 | if err != nil { 23 | log.Fatal(err) 24 | } 25 | 26 | // Setenv environment variable should not be able to be accessed by this action. 27 | if got, want := os.Getenv("set"), ""; got != want { 28 | errorf(`os.Getenv("set") = %s, want %s`, got, want) 29 | } 30 | 31 | // Exported environment variable should be able to be accessed by this action. 32 | if got, want := os.Getenv("export"), "export"; got != want { 33 | errorf(`os.Getenv("export") = %s, want %s`, got, want) 34 | } 35 | 36 | if fail { 37 | log.Fatalf("Failed...") 38 | } 39 | } 40 | 41 | func errorf(f string, args ...interface{}) { 42 | log.Printf(f, args...) 43 | fail = true 44 | } 45 | -------------------------------------------------------------------------------- /internal/comments/comments.go: -------------------------------------------------------------------------------- 1 | package comments 2 | 3 | import ( 4 | "go/ast" 5 | "go/token" 6 | "regexp" 7 | "strconv" 8 | ) 9 | 10 | var ( 11 | docRequired = regexp.MustCompile("^//goaction:required$") 12 | docSkip = regexp.MustCompile("^//goaction:skip$") 13 | docDefault = regexp.MustCompile("^//goaction:default (.*)$") 14 | docDesc = regexp.MustCompile("^//goaction:description (.*)$") 15 | ) 16 | 17 | // Comments holds information from doc string. 18 | type Comments struct { 19 | Required Bool 20 | Skip Bool 21 | Default String 22 | Desc String 23 | } 24 | 25 | type Bool struct { 26 | token.Pos 27 | Value bool 28 | } 29 | 30 | type String struct { 31 | token.Pos 32 | Value string 33 | } 34 | 35 | // parseComment searches for a special doc is a comment group. 36 | func (d *Comments) Parse(doc *ast.CommentGroup) { 37 | if doc == nil { 38 | return 39 | } 40 | for _, comment := range doc.List { 41 | txt := comment.Text 42 | pos := comment.Slash 43 | switch { 44 | case docRequired.MatchString(txt): 45 | d.Required = Bool{Value: true, Pos: pos} 46 | case docSkip.MatchString(txt): 47 | d.Skip = Bool{Value: true, Pos: pos} 48 | case docDefault.MatchString(txt): 49 | d.Default = String{Value: docDefault.FindStringSubmatch(txt)[1], Pos: pos} 50 | case docDesc.MatchString(txt): 51 | d.Desc = String{Value: strconv.Quote(docDesc.FindStringSubmatch(txt)[1]), Pos: pos} 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /internal/genapi/githubapi.go.gotmpl: -------------------------------------------------------------------------------- 1 | package actionutil 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | 7 | "golang.org/x/oauth2" 8 | "github.com/posener/goaction" 9 | "github.com/google/go-github/v31/github" 10 | ) 11 | 12 | // Client is a small wrapper around github.Client, that does not require to repeatedly type the 13 | // owner and repository in various function calls. 14 | type Client struct { 15 | *github.Client 16 | Owner string 17 | Project string 18 | } 19 | 20 | // NewClient returns a github client. 21 | func NewClient(c *http.Client) *Client { 22 | return &Client{ 23 | Client: github.NewClient(c), 24 | Owner: goaction.Owner(), 25 | Project: goaction.Project(), 26 | } 27 | } 28 | 29 | // NewClientWithToken returns a github client from a given auth token, according to 30 | // https://github.com/google/go-github#authentication. 31 | func NewClientWithToken(ctx context.Context, token string) *Client { 32 | ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) 33 | return NewClient(oauth2.NewClient(ctx, ts)) 34 | } 35 | 36 | {{ range . }} 37 | // {{ .Field.Name }}{{ .Method.Name }} calls the {{ .Field.Name }}.{{ .Method.Name }} method with 38 | // the relevant owner and repo arguments. 39 | func (c *Client) {{ .Field.Name }}{{ .Method.Name }}(ctx context.Context, {{ .OtherParamsDefinition }}) {{ .ResultsDefinition }} { 40 | return c.{{ .Field.Name }}.{{ .Method.Name }}(ctx, c.Owner, c.Project, {{ .OtherParamsUse }}) 41 | } 42 | {{ end }} 43 | -------------------------------------------------------------------------------- /internal/genevents/main.go: -------------------------------------------------------------------------------- 1 | // Generates events.go and events_test.go files. 2 | package main 3 | 4 | import ( 5 | "log" 6 | "strings" 7 | 8 | "github.com/posener/autogen" 9 | ) 10 | 11 | //go:generate go run . 12 | 13 | type event struct { 14 | Name string 15 | SkipEventGetFunc bool 16 | } 17 | 18 | func (e event) CamelCase() string { 19 | parts := strings.Split(e.Name, "_") 20 | for i := range parts { 21 | parts[i] = strings.Title(parts[i]) 22 | } 23 | return strings.Join(parts, "") 24 | } 25 | 26 | func (e event) Pretty() string { 27 | return strings.ReplaceAll(e.Name, "_", " ") 28 | } 29 | 30 | func (e event) EventGetFuncName() string { 31 | return "Get" + e.CamelCase() 32 | } 33 | 34 | func (e event) GithubReturnValue() string { 35 | return "github." + e.CamelCase() + "Event" 36 | } 37 | 38 | var events = []event{ 39 | {Name: "check_run"}, 40 | {Name: "check_suite"}, 41 | {Name: "create"}, 42 | {Name: "delete"}, 43 | {Name: "deployment"}, 44 | {Name: "fork"}, 45 | {Name: "gollum"}, 46 | {Name: "issue_comment"}, 47 | {Name: "issues"}, 48 | {Name: "label"}, 49 | {Name: "milestone"}, 50 | {Name: "page_build"}, 51 | {Name: "project"}, 52 | {Name: "project_card"}, 53 | {Name: "public"}, 54 | {Name: "pull_request"}, 55 | {Name: "pull_request_review"}, 56 | {Name: "pull_request_review_comment"}, 57 | {Name: "push"}, 58 | {Name: "registry_package", SkipEventGetFunc: true}, 59 | {Name: "release"}, 60 | {Name: "status"}, 61 | {Name: "watch"}, 62 | {Name: "schedule", SkipEventGetFunc: true}, 63 | {Name: "repository_dispatch"}, 64 | } 65 | 66 | func main() { 67 | err := autogen.Execute(events, autogen.Location(autogen.ModulePath)) 68 | if err != nil { 69 | log.Fatal(err) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /actionutil/github.go: -------------------------------------------------------------------------------- 1 | package actionutil 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "strings" 7 | 8 | "github.com/google/go-github/v31/github" 9 | "github.com/posener/goaction" 10 | "github.com/posener/goaction/log" 11 | ) 12 | 13 | // PRComment adds a comment to the curerrent pull request. If the comment already exists 14 | // it updates the exiting comment with the new content. 15 | func PRComment(ctx context.Context, token string, content string) error { 16 | var ( 17 | num = goaction.PrNum() 18 | 19 | // Hidden signature is added to the review comment body and is used in following runs to 20 | // identify which comment to update. 21 | hiddenSignature = fmt.Sprintf( 22 | "", 23 | goaction.Workflow, goaction.ActionID) 24 | ) 25 | gh := NewClientWithToken(ctx, token) 26 | 27 | // Look for an existing review. reviewID<0 means that we didn't find a matching review. 28 | reviewID := int64(-1) 29 | reviews, _, err := gh.PullRequestsListReviews(ctx, num, nil) 30 | if err != nil { 31 | return err 32 | } 33 | for _, review := range reviews { 34 | if strings.HasPrefix(review.GetBody(), hiddenSignature) { 35 | reviewID = review.GetID() 36 | break 37 | } 38 | } 39 | 40 | // Update or post a new review. 41 | commentBody := hiddenSignature + "\n\n" + content 42 | if reviewID >= 0 { 43 | log.Printf("Updating existing review: %d\n", reviewID) 44 | _, _, err = gh.PullRequestsUpdateReview(ctx, num, reviewID, commentBody) 45 | } else { 46 | log.Printf("Creating new review") 47 | _, _, err = gh.PullRequestsCreateReview(ctx, num, 48 | &github.PullRequestReviewRequest{ 49 | Body: github.String(commentBody), 50 | Event: github.String("COMMENT"), 51 | }) 52 | } 53 | return err 54 | } 55 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | # File generated by github.com/posener/goaction. DO NOT EDIT. 2 | 3 | name: posener/goaction 4 | description: "Creates action files for Go code" 5 | inputs: 6 | path: 7 | default: . 8 | description: "Path to main Go main package." 9 | required: true 10 | name: 11 | description: "Override action name, the default name is the package name." 12 | required: false 13 | desc: 14 | description: "Override action description, the default description is the package synopsis." 15 | required: false 16 | image: 17 | default: golang:1.14.2-alpine3.11 18 | description: "Override Docker image to run the action with (See https://hub.docker.com/_/golang?tab=tags)." 19 | required: false 20 | install: 21 | description: "Comma separated list of requirements to 'apk add'." 22 | required: false 23 | icon: 24 | description: "Set branding icon. (See options at https://feathericons.com)." 25 | required: false 26 | color: 27 | description: "Set branding color. (white, yellow, blue, green, orange, red, purple or gray-dark)." 28 | required: false 29 | email: 30 | default: posener@gmail.com 31 | description: "Email for commit message." 32 | required: false 33 | GITHUB_TOKEN: 34 | description: "Github token for PR comments. Optional." 35 | required: false 36 | runs: 37 | using: docker 38 | image: Dockerfile 39 | env: 40 | email: "${{ inputs.email }}" 41 | GITHUB_TOKEN: "${{ inputs.GITHUB_TOKEN }}" 42 | args: 43 | - "-path=${{ inputs.path }}" 44 | - "-name=${{ inputs.name }}" 45 | - "-desc=${{ inputs.desc }}" 46 | - "-image=${{ inputs.image }}" 47 | - "-install=${{ inputs.install }}" 48 | - "-icon=${{ inputs.icon }}" 49 | - "-color=${{ inputs.color }}" 50 | branding: 51 | icon: activity 52 | color: blue 53 | -------------------------------------------------------------------------------- /log/log_test.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "bytes" 5 | "go/token" 6 | "testing" 7 | 8 | "github.com/posener/goaction" 9 | "github.com/stretchr/testify/assert" 10 | ) 11 | 12 | func TestLog(t *testing.T) { 13 | old := goaction.CI 14 | defer func() { goaction.CI = old }() 15 | 16 | t.Run("CI=true", func(t *testing.T) { 17 | goaction.CI = true 18 | initFormats() 19 | 20 | want := `::debug::debugf foo 21 | printf foo 22 | ::warning::warnf foo 23 | ::error::errorf foo 24 | ::debug file=foo.go,line=10,col=3::debugf foo 25 | ::warning file=foo.go,line=10,col=3::warnf foo 26 | ::error file=foo.go,line=10,col=3::errorf foo 27 | ::debug file=foo.go::debugf foo 28 | ::warning file=foo.go::warnf foo 29 | ::error file=foo.go::errorf foo 30 | ` 31 | 32 | assert.Equal(t, want, logThings()) 33 | }) 34 | 35 | t.Run("CI=false", func(t *testing.T) { 36 | goaction.CI = false 37 | initFormats() 38 | 39 | want := `debugf foo 40 | printf foo 41 | warnf foo 42 | errorf foo 43 | foo.go+10:3: debugf foo 44 | foo.go+10:3: warnf foo 45 | foo.go+10:3: errorf foo 46 | foo.go: debugf foo 47 | foo.go: warnf foo 48 | foo.go: errorf foo 49 | ` 50 | 51 | assert.Equal(t, want, logThings()) 52 | }) 53 | } 54 | 55 | func logThings() string { 56 | var b bytes.Buffer 57 | logger.SetOutput(&b) 58 | 59 | Debugf("debugf %s", "foo") 60 | Printf("printf %s", "foo") 61 | Warnf("warnf %s", "foo") 62 | Errorf("errorf %s", "foo") 63 | 64 | p := token.Position{Filename: "foo.go", Line: 10, Column: 3} 65 | DebugfFile(p, "debugf %s", "foo") 66 | WarnfFile(p, "warnf %s", "foo") 67 | ErrorfFile(p, "errorf %s", "foo") 68 | 69 | p = token.Position{Filename: "foo.go"} 70 | DebugfFile(p, "debugf %s", "foo") 71 | WarnfFile(p, "warnf %s", "foo") 72 | ErrorfFile(p, "errorf %s", "foo") 73 | 74 | return b.String() 75 | } 76 | -------------------------------------------------------------------------------- /.github/workflows/testworkflow.yml: -------------------------------------------------------------------------------- 1 | # Test communication between different actions in a workflow. 2 | on: 3 | - pull_request 4 | - push 5 | jobs: 6 | prepare: 7 | runs-on: ubuntu-latest 8 | outputs: 9 | out: ${{ steps.prepare.outputs.out }} 10 | steps: 11 | - name: Install Go 12 | uses: actions/setup-go@v1 13 | with: 14 | go-version: 1.14.x 15 | - name: Checkout code 16 | uses: actions/checkout@v2 17 | - name: Install new version of goaction 18 | run: go build -o /tmp/goaction ./cmd/goaction 19 | # Prepare env and output that will be tested in other jobs. 20 | - name: Generate action files of prepare 21 | env: 22 | CI: false 23 | run: /tmp/goaction -path ./.github/tests/prepare 24 | - id: prepare 25 | name: Prepare 26 | uses: ./ 27 | 28 | # Test propagation of env set by prepare. Must run in the same job as the prepare step. 29 | - name: Generate action files of prepare test-env-set 30 | env: 31 | CI: false 32 | run: /tmp/goaction -path ./.github/tests/test-env-set 33 | - name: Test env-set 34 | uses: ./ 35 | tests: 36 | needs: prepare 37 | runs-on: ubuntu-latest 38 | steps: 39 | - name: Install Go 40 | uses: actions/setup-go@v1 41 | with: 42 | go-version: 1.14.x 43 | - name: Checkout code 44 | uses: actions/checkout@v2 45 | - name: Install new version of goaction 46 | run: go build -o /tmp/goaction ./cmd/goaction 47 | - name: Generate action files of test-input 48 | env: 49 | CI: false 50 | run: /tmp/goaction -path ./.github/tests/test-input 51 | - name: Test input 52 | uses: ./ 53 | with: 54 | message: ${{ needs.prepare.outputs.out }} 55 | arg: 42 56 | env: env 57 | -------------------------------------------------------------------------------- /actionutil/git.go: -------------------------------------------------------------------------------- 1 | package actionutil 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/posener/goaction" 8 | "github.com/posener/goaction/log" 9 | "github.com/posener/script" 10 | ) 11 | 12 | // GitConfig configures git with name and email to enable git operations. 13 | func GitConfig(name, email string) error { 14 | err := git("config", "user.name", name).ToStdout() 15 | if err != nil { 16 | return err 17 | } 18 | err = git("config", "user.email", email).ToStdout() 19 | if err != nil { 20 | return err 21 | } 22 | // Prevent errors "fatal: detected dubious ownership in repository at ...". 23 | return git("config", "--global", "--add", "safe.directory", "'*'").ToStdout() 24 | } 25 | 26 | // GitDiff returns diff of changes in a given file. 27 | func GitDiff(path string) (string, error) { 28 | // Add files to git, in case it does not exists 29 | err := git("add", path).ToStdout() 30 | defer func() { git("reset", path).ToStdout() }() 31 | if err != nil { 32 | return "", fmt.Errorf("git add for %s: %s", path, err) 33 | } 34 | return git("diff", "--staged", "--no-color", path).Tail(-5).ToString() 35 | } 36 | 37 | type Diff struct { 38 | Path string 39 | Diff string 40 | } 41 | 42 | // GitDiffAll returns diff of all changes in a given file. 43 | func GitDiffAll() ([]Diff, error) { 44 | // Add files to git, in case it does not exists 45 | err := git("add", ".").ToStdout() 46 | defer func() { git("reset").ToStdout() }() 47 | if err != nil { 48 | return nil, fmt.Errorf("git add: %s", err) 49 | } 50 | var diffs []Diff 51 | err = git("diff", "--staged", "--name-only").Iterate(func(path []byte) error { 52 | if len(path) == 0 { 53 | return nil 54 | } 55 | diff, err := git("diff", "--staged", "--no-color", string(path)).Tail(-5).ToString() 56 | if err != nil { 57 | return fmt.Errorf("git diff %q: %s", string(path), err) 58 | } 59 | diffs = append(diffs, Diff{Path: string(path), Diff: diff}) 60 | return nil 61 | }) 62 | return diffs, err 63 | } 64 | 65 | // GitCommitPush commits and pushes a list of files. 66 | func GitCommitPush(paths []string, message string) error { 67 | branch := goaction.Branch() 68 | 69 | // Reset git if there where any staged files. 70 | err := git("reset").ToStdout() 71 | if err != nil { 72 | return fmt.Errorf("git reset: %s", err) 73 | } 74 | 75 | // Add the requested paths. 76 | err = git("add", paths...).ToStdout() 77 | if err != nil { 78 | return fmt.Errorf("git add: %s", err) 79 | } 80 | 81 | // Commit the changes. 82 | err = git("commit", "-m", message).ToStdout() 83 | if err != nil { 84 | return fmt.Errorf("git commit: %s", err) 85 | } 86 | 87 | retry := 1 88 | maxRetries := 3 89 | for { 90 | // Push the change. 91 | err = git("push", "origin", "HEAD:"+branch).ToStdout() 92 | if err == nil { 93 | return nil 94 | } 95 | if retry > maxRetries { 96 | return fmt.Errorf("push failed %d times: %s", maxRetries, err) 97 | } 98 | retry++ 99 | // In case of push error, try to rebase and push again, in case the error was due to other 100 | // changes being pushed to the remote repository. 101 | log.Printf("Push failed, rebasing and trying again...") 102 | err = git("pull", "--rebase", "--autostash", "origin", branch).ToStdout() 103 | if err != nil { 104 | return fmt.Errorf("git pull rebase: %s", err) 105 | } 106 | } 107 | } 108 | 109 | func git(subcmd string, args ...string) script.Stream { 110 | args = append([]string{subcmd}, args...) 111 | return script.ExecHandleStderr(os.Stderr, "git", args...) 112 | } 113 | -------------------------------------------------------------------------------- /internal/genapi/main.go: -------------------------------------------------------------------------------- 1 | // Generates actionutil/githubapi.go 2 | package main 3 | 4 | import ( 5 | "fmt" 6 | "go/types" 7 | "log" 8 | "os" 9 | "path/filepath" 10 | "regexp" 11 | "strings" 12 | 13 | "github.com/posener/autogen" 14 | "golang.org/x/tools/go/loader" 15 | ) 16 | 17 | //go:generate go run . 18 | 19 | type fn struct { 20 | Field *types.Var 21 | Method *types.Func 22 | } 23 | 24 | func (f fn) Params() []*types.Var { 25 | var vars []*types.Var 26 | params := f.Method.Type().(*types.Signature).Params() 27 | for i := 0; i < params.Len(); i++ { 28 | vars = append(vars, params.At(i)) 29 | } 30 | return vars 31 | } 32 | 33 | func (f fn) Results() []*types.Var { 34 | var vars []*types.Var 35 | results := f.Method.Type().(*types.Signature).Results() 36 | for i := 0; i < results.Len(); i++ { 37 | vars = append(vars, results.At(i)) 38 | } 39 | return vars 40 | } 41 | 42 | func (f fn) OtherParamsDefinition() string { 43 | others := f.Params()[3:] 44 | var params []string 45 | for _, other := range others { 46 | params = append(params, fmt.Sprintf("%s %s", other.Name(), cleanTypeName(other.Type()))) 47 | } 48 | return strings.Join(params, ", ") 49 | } 50 | 51 | func (f fn) OtherParamsUse() string { 52 | others := f.Params()[3:] 53 | var params []string 54 | for _, other := range others { 55 | params = append(params, other.Name()) 56 | } 57 | return strings.Join(params, ", ") 58 | } 59 | 60 | func (f fn) ResultsDefinition() string { 61 | var params []string 62 | for _, other := range f.Results() { 63 | params = append(params, fmt.Sprintf("%s %s", other.Name(), cleanTypeName(other.Type()))) 64 | } 65 | ret := strings.Join(params, ", ") 66 | if len(params) > 1 { 67 | ret = "(" + ret + ")" 68 | } 69 | return ret 70 | } 71 | 72 | func (f fn) isValid() bool { 73 | params := f.Params() 74 | return len(params) >= 2 && 75 | params[0].Name() == "ctx" && 76 | params[1].Name() == "owner" && 77 | params[2].Name() == "repo" 78 | } 79 | 80 | func cleanTypeName(tp types.Type) string { 81 | name := tp.String() 82 | if i := strings.LastIndex(name, "/"); i >= 0 { 83 | prefix := regexp.MustCompile(`^[\[\]\*]*`).FindString(name) 84 | name = prefix + name[i+1:] 85 | } 86 | return name 87 | } 88 | 89 | func main() { 90 | log.SetFlags(log.Lshortfile) 91 | 92 | // Load the github program. 93 | conf := loader.Config{AllowErrors: true} 94 | conf.Import("github.com/google/go-github/v31/github") 95 | stderr := os.Stderr 96 | os.Stderr, _ = os.Open(os.DevNull) 97 | program, err := conf.Load() 98 | os.Stderr.Close() 99 | os.Stderr = stderr 100 | if err != nil { 101 | log.Fatal(err) 102 | } 103 | 104 | // Get github package. 105 | var pkg *types.Package 106 | for pkg = range program.AllPackages { 107 | if pkg.Name() == "github" { 108 | break 109 | } 110 | } 111 | if pkg == nil { 112 | log.Fatal("Package github was not found.") 113 | } 114 | 115 | // Get `type Client struct`: 116 | client := pkg.Scope().Lookup("Client").Type().Underlying().(*types.Struct) 117 | 118 | var funcs []fn 119 | 120 | // Iterate Client fields and collect the services. 121 | for i := 0; i < client.NumFields(); i++ { 122 | field := client.Field(i) 123 | if !field.Exported() { 124 | continue 125 | } 126 | // The field is a pointer to a struct, get the pointer. 127 | fieldPointer, ok := field.Type().Underlying().Underlying().(*types.Pointer) 128 | if !ok { 129 | continue 130 | } 131 | // The pointer points on a struct that ends with the "Service" suffix. 132 | fieldType, ok := fieldPointer.Elem().(*types.Named) 133 | if !ok { 134 | continue 135 | } 136 | if !strings.HasSuffix(fieldType.Obj().Name(), "Service") { 137 | continue 138 | } 139 | 140 | // Iterate over the field type methods. 141 | for j := 0; j < fieldType.NumMethods(); j++ { 142 | f := fn{Field: field, Method: fieldType.Method(j)} 143 | if !f.isValid() { 144 | continue 145 | } 146 | // Skip Repositories.GetArchiveLink: https://github.com/google/go-github/issues/1533. 147 | if f.Field.Name() == "Repositories" && f.Method.Name() == "GetArchiveLink" { 148 | continue 149 | } 150 | funcs = append(funcs, f) 151 | } 152 | } 153 | 154 | err = autogen.Execute( 155 | funcs, 156 | autogen.Location(filepath.Join(autogen.ModulePath, "actionutil"))) 157 | if err != nil { 158 | log.Fatal(err) 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /log/log.go: -------------------------------------------------------------------------------- 1 | // Package log is an alternative package for standard library "log" package for logging in Github 2 | // action environment. It behaves as expected both in CI mode and in non-CI mode. 3 | // 4 | // import ( 5 | // - "log" 6 | // + "github.com/posener/goaction/log" 7 | // ) 8 | package log 9 | 10 | import ( 11 | "fmt" 12 | "go/token" 13 | "log" 14 | "os" 15 | "strings" 16 | 17 | "github.com/posener/goaction" 18 | ) 19 | 20 | var logger *log.Logger 21 | 22 | const ( 23 | levelDebug level = "::debug%s::" 24 | levelWarn level = "::warning%s::" 25 | levelError level = "::error%s::" 26 | ) 27 | 28 | var ( 29 | // File position formattings: 30 | formatFile string 31 | formatLine string 32 | formatCol string 33 | formatJoin string 34 | ) 35 | 36 | func init() { 37 | out := os.Stdout 38 | if !goaction.CI { 39 | out = os.Stderr 40 | } 41 | logger = log.New(out, "", 0) 42 | initFormats() 43 | } 44 | 45 | // initFormats initializes format strings. Exists for testing purposes. 46 | func initFormats() { 47 | if goaction.CI { 48 | formatFile = "file=%s" 49 | formatLine = "line=%d" 50 | formatCol = "col=%d" 51 | formatJoin = "," 52 | } else { 53 | formatFile = "%s" 54 | formatLine = "+%d" 55 | formatCol = ":%d" 56 | formatJoin = "" 57 | } 58 | } 59 | 60 | type level string 61 | 62 | func (l level) format(p token.Position) string { 63 | pos := posString(p) 64 | if !goaction.CI { 65 | if len(pos) > 0 { 66 | pos = pos + ": " 67 | } 68 | return pos 69 | } 70 | if len(pos) > 0 { 71 | pos = " " + pos 72 | } 73 | return fmt.Sprintf(string(l), pos) 74 | } 75 | 76 | // Printf logs an info level message. 77 | func Printf(format string, args ...interface{}) { 78 | logger.Printf(format, args...) 79 | } 80 | 81 | // Debugf logs a debug level message. To view these logs, set secret ACTIONS_STEP_DEBUG=true at 82 | // https://github.com//settings/secrets/new. 83 | func Debugf(format string, args ...interface{}) { 84 | DebugfFile(token.Position{}, format, args...) 85 | } 86 | 87 | // DebugfFile logs a debug level message with a file location. To view these logs, set secret 88 | // variable ACTIONS_STEP_DEBUG=true at https://github.com//settings/secrets/new. 89 | func DebugfFile(p token.Position, format string, args ...interface{}) { 90 | logger.Printf(levelDebug.format(p)+format, args...) 91 | } 92 | 93 | // Warnf logs a warning level message. 94 | func Warnf(format string, args ...interface{}) { 95 | WarnfFile(token.Position{}, format, args...) 96 | } 97 | 98 | // WarnfFile logs a warning level message with a file location. 99 | func WarnfFile(p token.Position, format string, args ...interface{}) { 100 | logger.Printf(levelWarn.format(p)+format, args...) 101 | } 102 | 103 | // Errorf logs an error level message. 104 | func Errorf(format string, args ...interface{}) { 105 | ErrorfFile(token.Position{}, format, args...) 106 | } 107 | 108 | // ErrorfFile logs an error level message with a file location. 109 | func ErrorfFile(p token.Position, format string, args ...interface{}) { 110 | logger.Printf(levelError.format(p)+format, args...) 111 | } 112 | 113 | // Fatalf logs an error level message, and fails the program. 114 | func Fatalf(format string, args ...interface{}) { 115 | FatalfFile(token.Position{}, format, args...) 116 | } 117 | 118 | // FatalfFile logs an error level message with a file location, and fails the program. 119 | func FatalfFile(p token.Position, format string, args ...interface{}) { 120 | logger.Fatalf(levelError.format(p)+format, args...) 121 | } 122 | 123 | // Fatal logs an error level message, and fails the program. 124 | func Fatal(v ...interface{}) { 125 | FatalFile(token.Position{}, v...) 126 | } 127 | 128 | // FatalFile logs an error level message with a file location, and fails the program. 129 | func FatalFile(p token.Position, v ...interface{}) { 130 | logger.Fatal(append([]interface{}{levelError.format(p)}, v...)...) 131 | } 132 | 133 | func posString(p token.Position) string { 134 | if p.Filename == "" { 135 | return "" 136 | } 137 | 138 | parts := []string{fmt.Sprintf(formatFile, p.Filename)} 139 | if p.Line > 0 { 140 | parts = append(parts, fmt.Sprintf(formatLine, p.Line)) 141 | if p.Column > 0 { 142 | parts = append(parts, fmt.Sprintf(formatCol, p.Column)) 143 | } 144 | } 145 | return strings.Join(parts, formatJoin) 146 | } 147 | 148 | // Mask a term in the logs (will appear as '*' instead.) 149 | func Mask(term string) { 150 | if !goaction.CI { 151 | return 152 | } 153 | fmt.Println("::add-mask::" + term) 154 | } 155 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # goaction 2 | 3 | [![GoDoc](https://img.shields.io/badge/pkg.go.dev-doc-blue)](http://pkg.go.dev/github.com/posener/goaction) 4 | 5 | Package goaction enables writing Github Actions in Go. 6 | 7 | The idea is: write a standard Go script, one that works with `go run`, and use it as Github action. 8 | The script's inputs - flags and environment variables, are set though the Github action API. This 9 | project will generate all the required files for the script (This generation can be done 10 | automattically with Github action integration). The library also exposes neat API to get workflow 11 | information. 12 | 13 | ## Required Steps 14 | 15 | - [x] Write a Go script. 16 | 17 | - [x] Add `goaction` configuration in `.github/workflows/goaction.yml`. 18 | 19 | - [x] Push the project to Github. 20 | 21 | See simplest example for a Goaction script: [posener/goaction-example](https://github.com/posener/goaction-example), 22 | or an example that demonstrait using Github APIs: [posener/goaction-issues-example](https://github.com/posener/goaction-issues-example). 23 | 24 | ## Writing a Goaction Script 25 | 26 | Write Github Action by writing Go code! Just start a Go module with a main package, and execute it 27 | as a Github action using Goaction, or from the command line using `go run`. 28 | 29 | A go executable can get inputs from the command line flag and from environment variables. Github 30 | actions should have a `action.yml` file that defines this API. Goaction bridges the gap by parsing 31 | the Go code and creating this file automatically for you. 32 | 33 | The main package inputs should be defined with the standard `flag` package for command line 34 | arguments, or by `os.Getenv` for environment variables. These inputs define the API of the program 35 | and `goaction` automatically detect them and creates the `action.yml` file from them. 36 | 37 | Additionally, goaction also provides a library that exposes all Github action environment in an 38 | easy-to-use API. See the documentation for more information. 39 | 40 | Code segments which should run only in Github action (called "CI mode"), and not when the main 41 | package runs as a command line tool, should be protected by a `if goaction.CI { ... }` block. 42 | 43 | ## Goaction Configuration 44 | 45 | In order to convert the repository to a Github action, goaction command line should run on the 46 | **"main file"** (described above). This command can run manually (by [./cmd/goaction](./cmd/goaction)) but luckily 47 | `goaction` also comes as a Github action :-) 48 | 49 | Goaction Github action keeps the Github action file updated according to the main Go file 50 | automatically. When a PR is made, goaction will post a review explaining what changes to expect. 51 | When a new commit is pushed, Goaction makes sure that the Github action files are updated if needed. 52 | 53 | Add the following content to `.github/workflows/goaction.yml` 54 | 55 | ```go 56 | on: 57 | pull_request: 58 | branches: [main] 59 | push: 60 | branches: [main] 61 | permissions: 62 | # Goaction needs permissions to update pull requests comments and update contents. 63 | pull-requests: write 64 | contents: write 65 | jobs: 66 | goaction: 67 | runs-on: ubuntu-latest 68 | steps: 69 | - name: Check out repository 70 | uses: actions/checkout@v2 71 | - name: Update action files 72 | uses: posener/goaction@v1 73 | with: 74 | # Optional: required only for commenting on PRs. 75 | github-token: '${{ secrets.GITHUB_TOKEN }}' 76 | # Optional: now that the script is a Github action, it is possible to run it in the 77 | # workflow. 78 | - name: Example 79 | uses: [./](./) 80 | ``` 81 | 82 | ## Goaction Artifacts 83 | 84 | [./action.yml](./action.yml): A "metadata" file for Github actions. If this file exists, the repository is 85 | considered as Github action, and the file contains information that instructs how to invoke this 86 | action. See [metadata syntax](https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions). 87 | for more info. 88 | 89 | [./Dockerfile](./Dockerfile): A file that contains instructions how to build a container, that is used for Github 90 | actions. Github action uses this file in order to create a container image to the action. The 91 | container can also be built and tested manually: 92 | 93 | ```go 94 | $ docker build -t my-action . 95 | $ docker run --rm my-action 96 | ``` 97 | 98 | ## Annotations 99 | 100 | Goaction parses Go script file and looks for annotations that extends the information that exists in 101 | the function calls. Goaction annotations are a comments that start with `//goaction:` (no space 102 | after slashes). They can only be set on a `var` definition. The following annotations are available: 103 | 104 | * `//goaction:required` - sets an input definition to be "required". 105 | 106 | * `//goaction:skip` - skips an input out output definition. 107 | 108 | * `//goaction:description ` - add description for `os.Getenv`. 109 | 110 | * `//goaction:default ` - add default value for `os.Getenv`. 111 | 112 | ## Using Goaction 113 | 114 | A list of projects which are using Goaction (please send a PR if your project uses goaction and does 115 | not appear her). 116 | 117 | * [posener/goreadme](http://github.com/posener/goreadme) 118 | 119 | ## Sub Packages 120 | 121 | * [actionutil](./actionutil): Package actionutil provides utility functions for Github actions. 122 | 123 | * [log](./log): Package log is an alternative package for standard library "log" package for logging in Github action environment. 124 | 125 | --- 126 | Readme created from Go doc with [goreadme](https://github.com/posener/goreadme) 127 | -------------------------------------------------------------------------------- /cmd/goaction/main.go: -------------------------------------------------------------------------------- 1 | // Creates action files for Go code 2 | package main 3 | 4 | import ( 5 | "context" 6 | "errors" 7 | "flag" 8 | "fmt" 9 | "go/ast" 10 | "go/parser" 11 | "go/token" 12 | "io" 13 | "os" 14 | "path/filepath" 15 | "strings" 16 | "text/template" 17 | 18 | "github.com/goccy/go-yaml" 19 | "github.com/posener/goaction" 20 | "github.com/posener/goaction/actionutil" 21 | "github.com/posener/goaction/internal/metadata" 22 | "github.com/posener/goaction/log" 23 | "github.com/posener/script" 24 | ) 25 | 26 | var ( 27 | //goaction:required 28 | path = flag.String("path", ".", "Path to main Go main package.") 29 | name = flag.String("name", "", "Override action name, the default name is the package name.") 30 | desc = flag.String("desc", "", "Override action description, the default description is the package synopsis.") 31 | image = flag.String("image", "golang:1.14.2-alpine3.11", "Override Docker image to run the action with (See https://hub.docker.com/_/golang?tab=tags).") 32 | install = flag.String("install", "", "Comma separated list of requirements to 'apk add'.") 33 | icon = flag.String("icon", "", "Set branding icon. (See options at https://feathericons.com).") 34 | color = flag.String("color", "", "Set branding color. (white, yellow, blue, green, orange, red, purple or gray-dark).") 35 | 36 | //goaction:description Email for commit message. 37 | //goaction:default posener@gmail.com 38 | email = os.Getenv("email") 39 | //goaction:description Github token for PR comments. Optional. 40 | githubToken = os.Getenv("GITHUB_TOKEN") 41 | ) 42 | 43 | const ( 44 | action = "action.yml" 45 | dockerfile = "Dockerfile" 46 | autoComment = "# File generated by github.com/posener/goaction. DO NOT EDIT.\n\n" 47 | ) 48 | 49 | func main() { 50 | flag.Parse() 51 | 52 | // Load go code. 53 | fset := token.NewFileSet() 54 | pkgs, err := parser.ParseDir(fset, *path, nil, parser.ParseComments) 55 | if err != nil { 56 | log.Fatal(err) 57 | } 58 | 59 | // Get main package. 60 | var mainPkg *ast.Package 61 | for name, pkg := range pkgs { 62 | if name == "main" { 63 | mainPkg = pkg 64 | break 65 | } 66 | } 67 | if mainPkg == nil { 68 | log.Fatalf("No main package in path %q", *path) 69 | } 70 | 71 | // Parse Go code to Github actions metadata. 72 | m, err := metadata.New(mainPkg) 73 | if err != nil { 74 | // For parsing error, log the file location. 75 | var pe metadata.ErrParse 76 | if errors.As(err, &pe) { 77 | log.FatalFile(fset.Position(pe.Pos), err) 78 | } 79 | log.Fatal(err) 80 | } 81 | if *name != "" { 82 | m.Name = *name 83 | } 84 | if *desc != "" { 85 | m.Desc = *desc 86 | } 87 | 88 | m.Branding.Icon = *icon 89 | m.Branding.Color = *color 90 | 91 | // Applying changes. 92 | 93 | // Create action file. 94 | log.Printf("Writing %s\n", action) 95 | err = script.Writer("yml", func(w io.Writer) error { 96 | w.Write([]byte(autoComment)) 97 | return yaml.NewEncoder(w).Encode(m) 98 | }).ToFile(action) 99 | if err != nil { 100 | log.Fatal(err) 101 | } 102 | 103 | // Create dockerfile 104 | log.Printf("Writing %s\n", dockerfile) 105 | dir, err := pathRelDir(*path) 106 | data := tmplData{ 107 | Dir: dir, 108 | Image: *image, 109 | Install: strings.ReplaceAll(*install, ",", " "), 110 | } 111 | err = script.Writer("template", func(w io.Writer) error { 112 | w.Write([]byte(autoComment)) 113 | return tmpl.Execute(w, data) 114 | }).ToFile(dockerfile) 115 | if err != nil { 116 | log.Fatal(err) 117 | } 118 | 119 | diff := gitDiff() 120 | 121 | if diff != "" { 122 | log.Printf("Applied changes:\n\n%s\n\n", diff) 123 | } else { 124 | log.Printf("No changes were made.") 125 | } 126 | 127 | if !goaction.CI { 128 | return 129 | } 130 | 131 | err = actionutil.GitConfig("goaction", email) 132 | if err != nil { 133 | log.Fatal(err) 134 | } 135 | 136 | switch goaction.Event { 137 | case goaction.EventPush: 138 | log.Printf("Push mode.") 139 | if diff == "" { 140 | log.Printf("Skipping commit stage.") 141 | break 142 | } 143 | push() 144 | case goaction.EventPullRequest: 145 | log.Printf("Pull request mode.") 146 | pr(diff) 147 | default: 148 | log.Printf("Unsupported action mode: %s", goaction.Event) 149 | } 150 | } 151 | 152 | func gitDiff() string { 153 | var diff strings.Builder 154 | for _, path := range []string{action, dockerfile} { 155 | // Add files to git, in case it does not exists 156 | d, err := actionutil.GitDiff(path) 157 | if err != nil { 158 | log.Fatal(err) 159 | } 160 | if d != "" { 161 | diff.WriteString(fmt.Sprintf("Path `%s`:\n\n", path)) 162 | diff.WriteString(fmt.Sprintf("```diff\n%s\n```\n\n", d)) 163 | } 164 | } 165 | return diff.String() 166 | } 167 | 168 | // Commit and push chnages to upstream branch. 169 | func push() { 170 | err := actionutil.GitCommitPush( 171 | []string{action, dockerfile}, 172 | "Update action files") 173 | if err != nil { 174 | log.Fatal(err) 175 | } 176 | } 177 | 178 | // Post a pull request comment with the expected diff. 179 | func pr(diff string) { 180 | if githubToken == "" { 181 | log.Printf("In order to add request comment, set the GITHUB_TOKEN input.") 182 | return 183 | } 184 | 185 | body := "[Goaction](https://github.com/posener/goaction) will apply the following changes after PR is merged.\n\n" + diff 186 | if diff == "" { 187 | body = "[Goaction](https://github.com/posener/goaction) detected no required changes to Github action files." 188 | } 189 | 190 | ctx := context.Background() 191 | err := actionutil.PRComment(ctx, githubToken, body) 192 | if err != nil { 193 | log.Fatal(err) 194 | } 195 | } 196 | 197 | // pathRelDir returns the containing directory of a given path in a relative form, relative to the 198 | // working directory prefixed with "./" 199 | func pathRelDir(path string) (string, error) { 200 | path, err := filepath.Abs(path) 201 | if err != nil { 202 | return "", err 203 | } 204 | 205 | wd, err := os.Getwd() 206 | if err != nil { 207 | return "", err 208 | } 209 | 210 | path, err = filepath.Rel(wd, path) 211 | if err != nil { 212 | return "", err 213 | } 214 | // If Rel returned ".", fix it to empty string which will eventually mutate to "./". 215 | if path == "." { 216 | path = "" 217 | } 218 | // Add a "./" prefix. 219 | if !strings.HasPrefix(path, "./") { 220 | path = "./" + path 221 | } 222 | return path, nil 223 | } 224 | 225 | type tmplData struct { 226 | Dir string 227 | Image string 228 | Install string 229 | } 230 | 231 | var tmpl = template.Must(template.New("dockerfile").Parse(` 232 | FROM {{ .Image }} 233 | RUN apk add git {{ .Install }} 234 | 235 | COPY . /home/src 236 | WORKDIR /home/src 237 | RUN go build -o /bin/action {{ .Dir }} 238 | 239 | ENTRYPOINT [ "/bin/action" ] 240 | `)) 241 | -------------------------------------------------------------------------------- /event_test.go: -------------------------------------------------------------------------------- 1 | // Autogenerated by go run internal/genevents/main.go. DO NOT EDIT. 2 | 3 | package goaction 4 | 5 | // Code auto generated with `go run ./internal/genevents/main.go`. DO NOT EDIT 6 | 7 | import ( 8 | "bytes" 9 | "encoding/json" 10 | "testing" 11 | 12 | "github.com/stretchr/testify/assert" 13 | "github.com/stretchr/testify/require" 14 | ) 15 | 16 | func TestGetCheckRun(t *testing.T) { 17 | if Event != EventCheckRun { 18 | t.Skipf("Only applicatble for 'check run'") 19 | } 20 | event, err := GetCheckRun() 21 | assert.NoError(t, err) 22 | 23 | var out bytes.Buffer 24 | err = json.NewEncoder(&out).Encode(event) 25 | require.NoError(t, err) 26 | t.Log(out.String()) 27 | } 28 | 29 | func TestGetCheckSuite(t *testing.T) { 30 | if Event != EventCheckSuite { 31 | t.Skipf("Only applicatble for 'check suite'") 32 | } 33 | event, err := GetCheckSuite() 34 | assert.NoError(t, err) 35 | 36 | var out bytes.Buffer 37 | err = json.NewEncoder(&out).Encode(event) 38 | require.NoError(t, err) 39 | t.Log(out.String()) 40 | } 41 | 42 | func TestGetCreate(t *testing.T) { 43 | if Event != EventCreate { 44 | t.Skipf("Only applicatble for 'create'") 45 | } 46 | event, err := GetCreate() 47 | assert.NoError(t, err) 48 | 49 | var out bytes.Buffer 50 | err = json.NewEncoder(&out).Encode(event) 51 | require.NoError(t, err) 52 | t.Log(out.String()) 53 | } 54 | 55 | func TestGetDelete(t *testing.T) { 56 | if Event != EventDelete { 57 | t.Skipf("Only applicatble for 'delete'") 58 | } 59 | event, err := GetDelete() 60 | assert.NoError(t, err) 61 | 62 | var out bytes.Buffer 63 | err = json.NewEncoder(&out).Encode(event) 64 | require.NoError(t, err) 65 | t.Log(out.String()) 66 | } 67 | 68 | func TestGetDeployment(t *testing.T) { 69 | if Event != EventDeployment { 70 | t.Skipf("Only applicatble for 'deployment'") 71 | } 72 | event, err := GetDeployment() 73 | assert.NoError(t, err) 74 | 75 | var out bytes.Buffer 76 | err = json.NewEncoder(&out).Encode(event) 77 | require.NoError(t, err) 78 | t.Log(out.String()) 79 | } 80 | 81 | func TestGetFork(t *testing.T) { 82 | if Event != EventFork { 83 | t.Skipf("Only applicatble for 'fork'") 84 | } 85 | event, err := GetFork() 86 | assert.NoError(t, err) 87 | 88 | var out bytes.Buffer 89 | err = json.NewEncoder(&out).Encode(event) 90 | require.NoError(t, err) 91 | t.Log(out.String()) 92 | } 93 | 94 | func TestGetGollum(t *testing.T) { 95 | if Event != EventGollum { 96 | t.Skipf("Only applicatble for 'gollum'") 97 | } 98 | event, err := GetGollum() 99 | assert.NoError(t, err) 100 | 101 | var out bytes.Buffer 102 | err = json.NewEncoder(&out).Encode(event) 103 | require.NoError(t, err) 104 | t.Log(out.String()) 105 | } 106 | 107 | func TestGetIssueComment(t *testing.T) { 108 | if Event != EventIssueComment { 109 | t.Skipf("Only applicatble for 'issue comment'") 110 | } 111 | event, err := GetIssueComment() 112 | assert.NoError(t, err) 113 | 114 | var out bytes.Buffer 115 | err = json.NewEncoder(&out).Encode(event) 116 | require.NoError(t, err) 117 | t.Log(out.String()) 118 | } 119 | 120 | func TestGetIssues(t *testing.T) { 121 | if Event != EventIssues { 122 | t.Skipf("Only applicatble for 'issues'") 123 | } 124 | event, err := GetIssues() 125 | assert.NoError(t, err) 126 | 127 | var out bytes.Buffer 128 | err = json.NewEncoder(&out).Encode(event) 129 | require.NoError(t, err) 130 | t.Log(out.String()) 131 | } 132 | 133 | func TestGetLabel(t *testing.T) { 134 | if Event != EventLabel { 135 | t.Skipf("Only applicatble for 'label'") 136 | } 137 | event, err := GetLabel() 138 | assert.NoError(t, err) 139 | 140 | var out bytes.Buffer 141 | err = json.NewEncoder(&out).Encode(event) 142 | require.NoError(t, err) 143 | t.Log(out.String()) 144 | } 145 | 146 | func TestGetMilestone(t *testing.T) { 147 | if Event != EventMilestone { 148 | t.Skipf("Only applicatble for 'milestone'") 149 | } 150 | event, err := GetMilestone() 151 | assert.NoError(t, err) 152 | 153 | var out bytes.Buffer 154 | err = json.NewEncoder(&out).Encode(event) 155 | require.NoError(t, err) 156 | t.Log(out.String()) 157 | } 158 | 159 | func TestGetPageBuild(t *testing.T) { 160 | if Event != EventPageBuild { 161 | t.Skipf("Only applicatble for 'page build'") 162 | } 163 | event, err := GetPageBuild() 164 | assert.NoError(t, err) 165 | 166 | var out bytes.Buffer 167 | err = json.NewEncoder(&out).Encode(event) 168 | require.NoError(t, err) 169 | t.Log(out.String()) 170 | } 171 | 172 | func TestGetProject(t *testing.T) { 173 | if Event != EventProject { 174 | t.Skipf("Only applicatble for 'project'") 175 | } 176 | event, err := GetProject() 177 | assert.NoError(t, err) 178 | 179 | var out bytes.Buffer 180 | err = json.NewEncoder(&out).Encode(event) 181 | require.NoError(t, err) 182 | t.Log(out.String()) 183 | } 184 | 185 | func TestGetProjectCard(t *testing.T) { 186 | if Event != EventProjectCard { 187 | t.Skipf("Only applicatble for 'project card'") 188 | } 189 | event, err := GetProjectCard() 190 | assert.NoError(t, err) 191 | 192 | var out bytes.Buffer 193 | err = json.NewEncoder(&out).Encode(event) 194 | require.NoError(t, err) 195 | t.Log(out.String()) 196 | } 197 | 198 | func TestGetPublic(t *testing.T) { 199 | if Event != EventPublic { 200 | t.Skipf("Only applicatble for 'public'") 201 | } 202 | event, err := GetPublic() 203 | assert.NoError(t, err) 204 | 205 | var out bytes.Buffer 206 | err = json.NewEncoder(&out).Encode(event) 207 | require.NoError(t, err) 208 | t.Log(out.String()) 209 | } 210 | 211 | func TestGetPullRequest(t *testing.T) { 212 | if Event != EventPullRequest { 213 | t.Skipf("Only applicatble for 'pull request'") 214 | } 215 | event, err := GetPullRequest() 216 | assert.NoError(t, err) 217 | 218 | var out bytes.Buffer 219 | err = json.NewEncoder(&out).Encode(event) 220 | require.NoError(t, err) 221 | t.Log(out.String()) 222 | } 223 | 224 | func TestGetPullRequestReview(t *testing.T) { 225 | if Event != EventPullRequestReview { 226 | t.Skipf("Only applicatble for 'pull request review'") 227 | } 228 | event, err := GetPullRequestReview() 229 | assert.NoError(t, err) 230 | 231 | var out bytes.Buffer 232 | err = json.NewEncoder(&out).Encode(event) 233 | require.NoError(t, err) 234 | t.Log(out.String()) 235 | } 236 | 237 | func TestGetPullRequestReviewComment(t *testing.T) { 238 | if Event != EventPullRequestReviewComment { 239 | t.Skipf("Only applicatble for 'pull request review comment'") 240 | } 241 | event, err := GetPullRequestReviewComment() 242 | assert.NoError(t, err) 243 | 244 | var out bytes.Buffer 245 | err = json.NewEncoder(&out).Encode(event) 246 | require.NoError(t, err) 247 | t.Log(out.String()) 248 | } 249 | 250 | func TestGetPush(t *testing.T) { 251 | if Event != EventPush { 252 | t.Skipf("Only applicatble for 'push'") 253 | } 254 | event, err := GetPush() 255 | assert.NoError(t, err) 256 | 257 | var out bytes.Buffer 258 | err = json.NewEncoder(&out).Encode(event) 259 | require.NoError(t, err) 260 | t.Log(out.String()) 261 | } 262 | 263 | func TestGetRelease(t *testing.T) { 264 | if Event != EventRelease { 265 | t.Skipf("Only applicatble for 'release'") 266 | } 267 | event, err := GetRelease() 268 | assert.NoError(t, err) 269 | 270 | var out bytes.Buffer 271 | err = json.NewEncoder(&out).Encode(event) 272 | require.NoError(t, err) 273 | t.Log(out.String()) 274 | } 275 | 276 | func TestGetStatus(t *testing.T) { 277 | if Event != EventStatus { 278 | t.Skipf("Only applicatble for 'status'") 279 | } 280 | event, err := GetStatus() 281 | assert.NoError(t, err) 282 | 283 | var out bytes.Buffer 284 | err = json.NewEncoder(&out).Encode(event) 285 | require.NoError(t, err) 286 | t.Log(out.String()) 287 | } 288 | 289 | func TestGetWatch(t *testing.T) { 290 | if Event != EventWatch { 291 | t.Skipf("Only applicatble for 'watch'") 292 | } 293 | event, err := GetWatch() 294 | assert.NoError(t, err) 295 | 296 | var out bytes.Buffer 297 | err = json.NewEncoder(&out).Encode(event) 298 | require.NoError(t, err) 299 | t.Log(out.String()) 300 | } 301 | 302 | func TestGetRepositoryDispatch(t *testing.T) { 303 | if Event != EventRepositoryDispatch { 304 | t.Skipf("Only applicatble for 'repository dispatch'") 305 | } 306 | event, err := GetRepositoryDispatch() 307 | assert.NoError(t, err) 308 | 309 | var out bytes.Buffer 310 | err = json.NewEncoder(&out).Encode(event) 311 | require.NoError(t, err) 312 | t.Log(out.String()) 313 | } 314 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 3 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 5 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 6 | github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= 7 | github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= 8 | github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= 9 | github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= 10 | github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= 11 | github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= 12 | github.com/goccy/go-yaml v1.4.3 h1:+1jK1ost1TBEfWjciIMU8rciBq0poxurgS7XvLgQInM= 13 | github.com/goccy/go-yaml v1.4.3/go.mod h1:PsEEJ29nIFZL07P/c8dv4P6rQkVFFXafQee85U+ERHA= 14 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 15 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 16 | github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= 17 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 18 | github.com/google/go-github/v31 v31.0.0 h1:JJUxlP9lFK+ziXKimTCprajMApV1ecWD4NB6CCb0plo= 19 | github.com/google/go-github/v31 v31.0.0/go.mod h1:NQPZol8/1sMoWYGN2yaALIBytu17gAWfhbweiEed3pM= 20 | github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= 21 | github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= 22 | github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= 23 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= 24 | github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= 25 | github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= 26 | github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= 27 | github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= 28 | github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= 29 | github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= 30 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 31 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 32 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 33 | github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= 34 | github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= 35 | github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= 36 | github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 37 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 38 | github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= 39 | github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= 40 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 41 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 42 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 43 | github.com/posener/autogen v0.0.2 h1:Mw3UF18XT0eIG8Vu5SSFfHfNXNuuGowdyNP20UlB9pU= 44 | github.com/posener/autogen v0.0.2/go.mod h1:23ND5WRzjjNM+lOMUvy4WudgDikSK3Sm0rmaXAfnIWo= 45 | github.com/posener/script v1.1.5 h1:su+9YHNlevT+Hlq2Xul5skh5kYDIBE+x4xu+5mLDT9o= 46 | github.com/posener/script v1.1.5/go.mod h1:Rg3ijooqulo05aGLyGsHoLmIOUzHUVK19WVgrYBPU/E= 47 | github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= 48 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 49 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 50 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 51 | github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= 52 | github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= 53 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= 54 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 55 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 56 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= 57 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 58 | golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= 59 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 60 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ= 61 | golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 62 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 63 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= 64 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 65 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 66 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 67 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 68 | golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 69 | golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY= 70 | golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 71 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 72 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 73 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc= 74 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 75 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= 76 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 77 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 78 | google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= 79 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 80 | google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM= 81 | google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= 82 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 83 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 84 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= 85 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 86 | gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= 87 | gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= 88 | gopkg.in/go-playground/validator.v9 v9.30.0 h1:Wk0Z37oBmKj9/n+tPyBHZmeL19LaCoK3Qq48VwYENss= 89 | gopkg.in/go-playground/validator.v9 v9.30.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= 90 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 91 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 92 | gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2 h1:XZx7nhd5GMaZpmDaEHFVafUZC7ya0fuo7cSJ3UCKYmM= 93 | gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 94 | -------------------------------------------------------------------------------- /internal/metadata/metadata_test.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | import ( 4 | "go/ast" 5 | "go/parser" 6 | "go/token" 7 | "strings" 8 | "testing" 9 | 10 | "github.com/goccy/go-yaml" 11 | "github.com/stretchr/testify/assert" 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func TestNew(t *testing.T) { 16 | t.Parallel() 17 | 18 | code := ` 19 | // Package main tests parsing of input calls. 20 | package main 21 | 22 | import ( 23 | "flag" 24 | "os" 25 | "github.com/posener/goaction" 26 | ) 27 | 28 | var ( 29 | _ = flag.String("string", "", "string usage") 30 | _ = flag.String("string-default", "default", "string default usage") 31 | _ = flag.Int("int", 1, "int usage") 32 | _ = flag.Bool("bool-true", true, "bool true usage") 33 | _ = flag.Bool("bool-false", false, "bool false usage") 34 | 35 | _ = os.Getenv("env") 36 | 37 | s string 38 | i int 39 | b bool 40 | ) 41 | 42 | func init() { 43 | flag.StringVar(&s, "string-var", "", "string var usage") 44 | flag.StringVar(&s, "string-var-default", "default", "string var default usage") 45 | flag.IntVar(&i, "int-var", 0, "int var usage") 46 | flag.BoolVar(&b, "bool-var-true", true, "bool var true usage") 47 | flag.BoolVar(&b, "bool-var-false", false, "bool var false usage") 48 | } 49 | 50 | func main() { 51 | goaction.Output("out", "value", "output description") 52 | } 53 | ` 54 | 55 | var want = Metadata{ 56 | Name: "main", 57 | Desc: "\"Package main tests parsing of input calls.\"", 58 | Inputs: yaml.MapSlice{ 59 | {"string", Input{tp: inputFlag, Desc: "\"string usage\""}}, 60 | {"string-default", Input{tp: inputFlag, Default: "default", Desc: "\"string default usage\""}}, 61 | {"int", Input{tp: inputFlag, Default: 1, Desc: "\"int usage\""}}, 62 | {"bool-true", Input{tp: inputFlag, Default: true, Desc: "\"bool true usage\""}}, 63 | {"bool-false", Input{tp: inputFlag, Default: false, Desc: "\"bool false usage\""}}, 64 | {"env", Input{tp: inputEnv}}, 65 | {"string-var", Input{tp: inputFlag, Desc: "\"string var usage\""}}, 66 | {"string-var-default", Input{tp: inputFlag, Default: "default", Desc: "\"string var default usage\""}}, 67 | {"int-var", Input{tp: inputFlag, Default: 0, Desc: "\"int var usage\""}}, 68 | {"bool-var-true", Input{tp: inputFlag, Default: true, Desc: "\"bool var true usage\""}}, 69 | {"bool-var-false", Input{tp: inputFlag, Default: false, Desc: "\"bool var false usage\""}}, 70 | }, 71 | Outputs: yaml.MapSlice{ 72 | {"out", Output{Desc: "\"output description\""}}, 73 | }, 74 | Runs: Runs{ 75 | Using: "docker", 76 | Image: "Dockerfile", 77 | Args: []string{ 78 | "\"-string=${{ inputs.string }}\"", 79 | "\"-string-default=${{ inputs.string-default }}\"", 80 | "\"-int=${{ inputs.int }}\"", 81 | "\"-bool-true=${{ inputs.bool-true }}\"", 82 | "\"-bool-false=${{ inputs.bool-false }}\"", 83 | "\"-string-var=${{ inputs.string-var }}\"", 84 | "\"-string-var-default=${{ inputs.string-var-default }}\"", 85 | "\"-int-var=${{ inputs.int-var }}\"", 86 | "\"-bool-var-true=${{ inputs.bool-var-true }}\"", 87 | "\"-bool-var-false=${{ inputs.bool-var-false }}\"", 88 | }, 89 | Env: yaml.MapSlice{ 90 | {"env", "\"${{ inputs.env }}\""}, 91 | }, 92 | }, 93 | } 94 | 95 | got, err := parse(code) 96 | if err != nil { 97 | t.Fatal(err) 98 | } 99 | assert.Equal(t, want, got) 100 | } 101 | 102 | // Tests cases of goaction:required comment. 103 | func TestNewRequired(t *testing.T) { 104 | t.Parallel() 105 | 106 | code := ` 107 | package main 108 | 109 | import ( 110 | "flag" 111 | "os" 112 | "github.com/posener/goaction" 113 | ) 114 | 115 | var ( 116 | // Test two following definitions. The required should apply only to the first. 117 | //goaction:required 118 | _ = flag.String("simple1", "", "simple1") 119 | _ = flag.String("simple2", "", "simple2") 120 | 121 | // Test multiple definitions. 122 | //goaction:required 123 | _, _ = flag.String("multi1", "", "multi1"), flag.String("multi2", "", "multi2") 124 | ) 125 | 126 | // Test var definition. 127 | //goaction:required 128 | var _ = flag.String("var", "", "var") 129 | 130 | // Test var block. 131 | //goaction:required 132 | var ( 133 | _ = flag.String("block1", "", "block1") 134 | _ = flag.String("block2", "", "block2") 135 | ) 136 | 137 | var ( 138 | // Test environment variable required and description. 139 | //goaction:required 140 | _ = os.Getenv("env") 141 | ) 142 | ` 143 | 144 | var wantInputs = yaml.MapSlice{ 145 | {"simple1", Input{tp: inputFlag, Desc: "\"simple1\"", Required: true}}, 146 | {"simple2", Input{tp: inputFlag, Desc: "\"simple2\""}}, 147 | {"multi1", Input{tp: inputFlag, Desc: "\"multi1\"", Required: true}}, 148 | {"multi2", Input{tp: inputFlag, Desc: "\"multi2\"", Required: true}}, 149 | {"var", Input{tp: inputFlag, Desc: "\"var\"", Required: true}}, 150 | {"block1", Input{tp: inputFlag, Desc: "\"block1\"", Required: true}}, 151 | {"block2", Input{tp: inputFlag, Desc: "\"block2\"", Required: true}}, 152 | {"env", Input{tp: inputEnv, Required: true}}, 153 | } 154 | 155 | got, err := parse(code) 156 | if err != nil { 157 | t.Fatal(err) 158 | } 159 | assert.Equal(t, wantInputs, got.Inputs) 160 | } 161 | 162 | func TestNewDefaultDesc(t *testing.T) { 163 | t.Parallel() 164 | 165 | code := ` 166 | package main 167 | 168 | import ( 169 | "flag" 170 | "os" 171 | "github.com/posener/goaction" 172 | ) 173 | 174 | // Test environment variable required and description. 175 | //goaction:default default 176 | //goaction:description input from environment variable 177 | var _ = os.Getenv("env") 178 | ` 179 | 180 | var wantInputs = yaml.MapSlice{ 181 | {"env", Input{tp: inputEnv, Default: "default", Desc: "\"input from environment variable\""}}, 182 | } 183 | 184 | got, err := parse(code) 185 | if err != nil { 186 | t.Fatal(err) 187 | } 188 | assert.Equal(t, wantInputs, got.Inputs) 189 | } 190 | 191 | // Tests cases of goaction:skip comment. 192 | func TestNewSkip(t *testing.T) { 193 | t.Parallel() 194 | 195 | code := ` 196 | package main 197 | 198 | import ( 199 | "flag" 200 | "github.com/posener/goaction" 201 | ) 202 | 203 | var ( 204 | // Test two following definitions. The skip should apply only to the first. 205 | //goaction:skip 206 | _ = flag.String("simple1", "", "simple1") 207 | _ = flag.String("simple2", "", "simple2") 208 | 209 | // Test multiple definitions. 210 | //goaction:skip 211 | _, _ = flag.String("multi1", "", "multi1"), flag.String("multi2", "", "multi2") 212 | ) 213 | 214 | // Test var definition. 215 | //goaction:skip 216 | var _ = flag.String("var", "", "var") 217 | 218 | // Test var block. 219 | //goaction:skip 220 | var ( 221 | _ = flag.String("block1", "", "block1") 222 | _ = flag.String("block2", "", "block2") 223 | ) 224 | 225 | var ( 226 | // Test environment variable required and description. 227 | //goaction:skip 228 | _ = os.Getenv("env") 229 | ) 230 | ` 231 | 232 | var wantInputs = yaml.MapSlice{ 233 | {"simple2", Input{tp: inputFlag, Desc: "\"simple2\""}}, 234 | } 235 | 236 | got, err := parse(code) 237 | if err != nil { 238 | t.Fatal(err) 239 | } 240 | assert.Equal(t, wantInputs, got.Inputs) 241 | } 242 | 243 | func TestNewInvalidAnnotations(t *testing.T) { 244 | t.Parallel() 245 | 246 | codes := []string{ 247 | ` 248 | package main 249 | import "flag" 250 | 251 | //goaction:description description 252 | var _ = flag.String("simple1", "", "simple1") 253 | `, 254 | ` 255 | package main 256 | import "flag" 257 | 258 | //goaction:default default 259 | var _ = flag.String("simple1", "", "simple1") 260 | `, 261 | } 262 | 263 | for _, code := range codes { 264 | t.Run(code, func(t *testing.T) { 265 | _, err := parse(strings.TrimSpace(code)) 266 | assert.Error(t, err) 267 | }) 268 | } 269 | } 270 | 271 | func TestMarshal(t *testing.T) { 272 | m := Metadata{ 273 | Name: "name", 274 | Desc: "description", 275 | Inputs: yaml.MapSlice{ 276 | {"in2", Input{tp: "tp2", Default: 1, Desc: "description 2"}}, 277 | {"in1", Input{tp: "tp1", Default: "string", Desc: "description 1"}}, 278 | }, 279 | Runs: Runs{ 280 | Using: "using", 281 | Image: "image", 282 | Args: []string{"arg1", "arg2"}, 283 | Env: yaml.MapSlice{ 284 | {"key2", "value2"}, 285 | {"key1", "value1"}, 286 | }, 287 | }, 288 | } 289 | 290 | m.Branding.Color = "color" 291 | m.Branding.Icon = "icon" 292 | 293 | want := `name: name 294 | description: description 295 | inputs: 296 | in2: 297 | default: 1 298 | description: description 2 299 | required: false 300 | in1: 301 | default: string 302 | description: description 1 303 | required: false 304 | runs: 305 | using: using 306 | image: image 307 | env: 308 | key2: value2 309 | key1: value1 310 | args: 311 | - arg1 312 | - arg2 313 | branding: 314 | icon: icon 315 | color: color 316 | ` 317 | got, err := yaml.Marshal(m) 318 | require.NoError(t, err) 319 | assert.Equal(t, want, string(got)) 320 | } 321 | 322 | func parse(code string) (Metadata, error) { 323 | fset := token.NewFileSet() 324 | f, err := parser.ParseFile(fset, "main.go", code, parser.ParseComments) 325 | if err != nil { 326 | return Metadata{}, err 327 | } 328 | pkg := &ast.Package{ 329 | Name: "main", 330 | Files: map[string]*ast.File{"main.go": f}, 331 | } 332 | return New(pkg) 333 | } 334 | -------------------------------------------------------------------------------- /event.go: -------------------------------------------------------------------------------- 1 | // Autogenerated by go run internal/genevents/main.go. DO NOT EDIT. 2 | 3 | package goaction 4 | 5 | import ( 6 | "encoding/json" 7 | "fmt" 8 | "os" 9 | 10 | "github.com/google/go-github/v31/github" 11 | ) 12 | 13 | // A Github action triggering event. 14 | // See https://help.github.com/en/actions/reference/events-that-trigger-workflows. 15 | type EventType string 16 | 17 | // All Github action event types. 18 | const ( 19 | EventCheckRun EventType = "check_run" 20 | EventCheckSuite EventType = "check_suite" 21 | EventCreate EventType = "create" 22 | EventDelete EventType = "delete" 23 | EventDeployment EventType = "deployment" 24 | EventFork EventType = "fork" 25 | EventGollum EventType = "gollum" 26 | EventIssueComment EventType = "issue_comment" 27 | EventIssues EventType = "issues" 28 | EventLabel EventType = "label" 29 | EventMilestone EventType = "milestone" 30 | EventPageBuild EventType = "page_build" 31 | EventProject EventType = "project" 32 | EventProjectCard EventType = "project_card" 33 | EventPublic EventType = "public" 34 | EventPullRequest EventType = "pull_request" 35 | EventPullRequestReview EventType = "pull_request_review" 36 | EventPullRequestReviewComment EventType = "pull_request_review_comment" 37 | EventPush EventType = "push" 38 | EventRegistryPackage EventType = "registry_package" 39 | EventRelease EventType = "release" 40 | EventStatus EventType = "status" 41 | EventWatch EventType = "watch" 42 | EventSchedule EventType = "schedule" 43 | EventRepositoryDispatch EventType = "repository_dispatch" 44 | ) 45 | 46 | // GetCheckRun returns information about a current check run. 47 | func GetCheckRun() (*github.CheckRunEvent, error) { 48 | if Event != EventCheckRun { 49 | return nil, fmt.Errorf("not 'check_run' event") 50 | } 51 | var i github.CheckRunEvent 52 | err := decodeEventInfo(&i) 53 | return &i, err 54 | } 55 | 56 | // GetCheckSuite returns information about a current check suite. 57 | func GetCheckSuite() (*github.CheckSuiteEvent, error) { 58 | if Event != EventCheckSuite { 59 | return nil, fmt.Errorf("not 'check_suite' event") 60 | } 61 | var i github.CheckSuiteEvent 62 | err := decodeEventInfo(&i) 63 | return &i, err 64 | } 65 | 66 | // GetCreate returns information about a current create. 67 | func GetCreate() (*github.CreateEvent, error) { 68 | if Event != EventCreate { 69 | return nil, fmt.Errorf("not 'create' event") 70 | } 71 | var i github.CreateEvent 72 | err := decodeEventInfo(&i) 73 | return &i, err 74 | } 75 | 76 | // GetDelete returns information about a current delete. 77 | func GetDelete() (*github.DeleteEvent, error) { 78 | if Event != EventDelete { 79 | return nil, fmt.Errorf("not 'delete' event") 80 | } 81 | var i github.DeleteEvent 82 | err := decodeEventInfo(&i) 83 | return &i, err 84 | } 85 | 86 | // GetDeployment returns information about a current deployment. 87 | func GetDeployment() (*github.DeploymentEvent, error) { 88 | if Event != EventDeployment { 89 | return nil, fmt.Errorf("not 'deployment' event") 90 | } 91 | var i github.DeploymentEvent 92 | err := decodeEventInfo(&i) 93 | return &i, err 94 | } 95 | 96 | // GetFork returns information about a current fork. 97 | func GetFork() (*github.ForkEvent, error) { 98 | if Event != EventFork { 99 | return nil, fmt.Errorf("not 'fork' event") 100 | } 101 | var i github.ForkEvent 102 | err := decodeEventInfo(&i) 103 | return &i, err 104 | } 105 | 106 | // GetGollum returns information about a current gollum. 107 | func GetGollum() (*github.GollumEvent, error) { 108 | if Event != EventGollum { 109 | return nil, fmt.Errorf("not 'gollum' event") 110 | } 111 | var i github.GollumEvent 112 | err := decodeEventInfo(&i) 113 | return &i, err 114 | } 115 | 116 | // GetIssueComment returns information about a current issue comment. 117 | func GetIssueComment() (*github.IssueCommentEvent, error) { 118 | if Event != EventIssueComment { 119 | return nil, fmt.Errorf("not 'issue_comment' event") 120 | } 121 | var i github.IssueCommentEvent 122 | err := decodeEventInfo(&i) 123 | return &i, err 124 | } 125 | 126 | // GetIssues returns information about a current issues. 127 | func GetIssues() (*github.IssuesEvent, error) { 128 | if Event != EventIssues { 129 | return nil, fmt.Errorf("not 'issues' event") 130 | } 131 | var i github.IssuesEvent 132 | err := decodeEventInfo(&i) 133 | return &i, err 134 | } 135 | 136 | // GetLabel returns information about a current label. 137 | func GetLabel() (*github.LabelEvent, error) { 138 | if Event != EventLabel { 139 | return nil, fmt.Errorf("not 'label' event") 140 | } 141 | var i github.LabelEvent 142 | err := decodeEventInfo(&i) 143 | return &i, err 144 | } 145 | 146 | // GetMilestone returns information about a current milestone. 147 | func GetMilestone() (*github.MilestoneEvent, error) { 148 | if Event != EventMilestone { 149 | return nil, fmt.Errorf("not 'milestone' event") 150 | } 151 | var i github.MilestoneEvent 152 | err := decodeEventInfo(&i) 153 | return &i, err 154 | } 155 | 156 | // GetPageBuild returns information about a current page build. 157 | func GetPageBuild() (*github.PageBuildEvent, error) { 158 | if Event != EventPageBuild { 159 | return nil, fmt.Errorf("not 'page_build' event") 160 | } 161 | var i github.PageBuildEvent 162 | err := decodeEventInfo(&i) 163 | return &i, err 164 | } 165 | 166 | // GetProject returns information about a current project. 167 | func GetProject() (*github.ProjectEvent, error) { 168 | if Event != EventProject { 169 | return nil, fmt.Errorf("not 'project' event") 170 | } 171 | var i github.ProjectEvent 172 | err := decodeEventInfo(&i) 173 | return &i, err 174 | } 175 | 176 | // GetProjectCard returns information about a current project card. 177 | func GetProjectCard() (*github.ProjectCardEvent, error) { 178 | if Event != EventProjectCard { 179 | return nil, fmt.Errorf("not 'project_card' event") 180 | } 181 | var i github.ProjectCardEvent 182 | err := decodeEventInfo(&i) 183 | return &i, err 184 | } 185 | 186 | // GetPublic returns information about a current public. 187 | func GetPublic() (*github.PublicEvent, error) { 188 | if Event != EventPublic { 189 | return nil, fmt.Errorf("not 'public' event") 190 | } 191 | var i github.PublicEvent 192 | err := decodeEventInfo(&i) 193 | return &i, err 194 | } 195 | 196 | // GetPullRequest returns information about a current pull request. 197 | func GetPullRequest() (*github.PullRequestEvent, error) { 198 | if Event != EventPullRequest { 199 | return nil, fmt.Errorf("not 'pull_request' event") 200 | } 201 | var i github.PullRequestEvent 202 | err := decodeEventInfo(&i) 203 | return &i, err 204 | } 205 | 206 | // GetPullRequestReview returns information about a current pull request review. 207 | func GetPullRequestReview() (*github.PullRequestReviewEvent, error) { 208 | if Event != EventPullRequestReview { 209 | return nil, fmt.Errorf("not 'pull_request_review' event") 210 | } 211 | var i github.PullRequestReviewEvent 212 | err := decodeEventInfo(&i) 213 | return &i, err 214 | } 215 | 216 | // GetPullRequestReviewComment returns information about a current pull request review comment. 217 | func GetPullRequestReviewComment() (*github.PullRequestReviewCommentEvent, error) { 218 | if Event != EventPullRequestReviewComment { 219 | return nil, fmt.Errorf("not 'pull_request_review_comment' event") 220 | } 221 | var i github.PullRequestReviewCommentEvent 222 | err := decodeEventInfo(&i) 223 | return &i, err 224 | } 225 | 226 | // GetPush returns information about a current push. 227 | func GetPush() (*github.PushEvent, error) { 228 | if Event != EventPush { 229 | return nil, fmt.Errorf("not 'push' event") 230 | } 231 | var i github.PushEvent 232 | err := decodeEventInfo(&i) 233 | return &i, err 234 | } 235 | 236 | // GetRelease returns information about a current release. 237 | func GetRelease() (*github.ReleaseEvent, error) { 238 | if Event != EventRelease { 239 | return nil, fmt.Errorf("not 'release' event") 240 | } 241 | var i github.ReleaseEvent 242 | err := decodeEventInfo(&i) 243 | return &i, err 244 | } 245 | 246 | // GetStatus returns information about a current status. 247 | func GetStatus() (*github.StatusEvent, error) { 248 | if Event != EventStatus { 249 | return nil, fmt.Errorf("not 'status' event") 250 | } 251 | var i github.StatusEvent 252 | err := decodeEventInfo(&i) 253 | return &i, err 254 | } 255 | 256 | // GetWatch returns information about a current watch. 257 | func GetWatch() (*github.WatchEvent, error) { 258 | if Event != EventWatch { 259 | return nil, fmt.Errorf("not 'watch' event") 260 | } 261 | var i github.WatchEvent 262 | err := decodeEventInfo(&i) 263 | return &i, err 264 | } 265 | 266 | // GetRepositoryDispatch returns information about a current repository dispatch. 267 | func GetRepositoryDispatch() (*github.RepositoryDispatchEvent, error) { 268 | if Event != EventRepositoryDispatch { 269 | return nil, fmt.Errorf("not 'repository_dispatch' event") 270 | } 271 | var i github.RepositoryDispatchEvent 272 | err := decodeEventInfo(&i) 273 | return &i, err 274 | } 275 | 276 | func decodeEventInfo(i interface{}) error { 277 | f, err := os.Open(eventPath) 278 | if err != nil { 279 | return err 280 | } 281 | defer f.Close() 282 | return json.NewDecoder(f).Decode(i) 283 | } 284 | -------------------------------------------------------------------------------- /internal/metadata/metadata.go: -------------------------------------------------------------------------------- 1 | // Package metadata loads main go file to a datastructure that describes Github action metadata. 2 | package metadata 3 | 4 | import ( 5 | "fmt" 6 | "go/ast" 7 | "go/doc" 8 | "go/token" 9 | "strconv" 10 | 11 | "github.com/goccy/go-yaml" 12 | "github.com/posener/goaction/internal/comments" 13 | ) 14 | 15 | const ( 16 | inputFlag = "flag" 17 | inputEnv = "env" 18 | ) 19 | 20 | type ErrParse struct { 21 | Pos token.Pos 22 | error 23 | } 24 | 25 | // Metadata represents the structure of Github actions metadata yaml file. 26 | // See https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions. 27 | type Metadata struct { 28 | Name string 29 | Desc string `yaml:"description,omitempty"` 30 | Inputs yaml.MapSlice `yaml:",omitempty"` // map[string]Input 31 | Outputs yaml.MapSlice `yaml:",omitempty"` // map[string]Output 32 | Runs Runs 33 | // Branding of Github action. 34 | // See https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions#branding 35 | Branding struct { 36 | Icon string `yaml:",omitempty"` 37 | Color string `yaml:",omitempty"` 38 | } `yaml:",omitempty"` 39 | } 40 | 41 | // Input for a Github action. 42 | // See https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions#inputs. 43 | type Input struct { 44 | Default interface{} `yaml:",omitempty"` 45 | Desc string `yaml:"description,omitempty"` 46 | Required bool 47 | 48 | tp string 49 | } 50 | 51 | // Output for Github action. 52 | // See https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions#outputs. 53 | type Output struct { 54 | Desc string `yaml:"description"` 55 | } 56 | 57 | // Runs section for "Docker" Github action. 58 | // See https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions#runs-for-docker-actions. 59 | type Runs struct { 60 | Using string // Alwasy "docker" 61 | Image string 62 | Env yaml.MapSlice `yaml:",omitempty"` // map[string]string 63 | Args []string `yaml:",omitempty"` 64 | } 65 | 66 | func New(pkg *ast.Package) (Metadata, error) { 67 | // pkgDoc := doc.New(pkg, "", doc.AllDecls) 68 | m := Metadata{ 69 | Name: pkg.Name, 70 | // Desc: strconv.Quote(doc.Synopsis(pkgDoc.Doc)), 71 | Runs: Runs{ 72 | Using: "docker", 73 | Image: "Dockerfile", 74 | }, 75 | } 76 | 77 | var err error 78 | ast.Inspect(pkg, func(n ast.Node) bool { 79 | defer func() { 80 | e := recover() 81 | if e == nil { 82 | return 83 | } 84 | var ok bool 85 | err, ok = e.(ErrParse) 86 | if !ok { 87 | panic(e) 88 | } 89 | }() 90 | return m.inspect(n, comments.Comments{}) 91 | }) 92 | if err != nil { 93 | return m, err 94 | } 95 | m.Runs.Args, err = calcArgs(m.Inputs) 96 | if err != nil { 97 | return m, err 98 | } 99 | m.Runs.Env, err = calcEnv(m.Inputs) 100 | if err != nil { 101 | return m, err 102 | } 103 | 104 | return m, nil 105 | } 106 | 107 | func (m *Metadata) AddInput(name string, in Input) { 108 | m.Inputs = append(m.Inputs, yaml.MapItem{Key: name, Value: in}) 109 | } 110 | 111 | func (m *Metadata) AddOutput(name string, out Output) { 112 | m.Outputs = append(m.Outputs, yaml.MapItem{Key: name, Value: out}) 113 | } 114 | 115 | // Inspect might panic with `parseError` when parsing failed. 116 | func (m *Metadata) inspect(n ast.Node, d comments.Comments) bool { 117 | switch v := n.(type) { 118 | case *ast.File: 119 | if v.Doc != nil { 120 | m.Desc = strconv.Quote(doc.Synopsis(v.Doc.Text())) 121 | } 122 | return true 123 | case *ast.GenDecl: 124 | // Decleration definition, catches "var ( ... )" segments. 125 | m.inspectDecl(v, d) 126 | return false 127 | case *ast.ValueSpec: 128 | // Value definition, catches "v := package.Func(...)"" calls." 129 | m.inspectValue(v, d) 130 | return false // Covered all inspections, no need to inspect down this node. 131 | case *ast.CallExpr: 132 | m.inspectCall(v, d) 133 | return true // Continue inspecting, maybe there is another call in this call. 134 | } 135 | return true 136 | } 137 | 138 | func (m *Metadata) inspectDecl(decl *ast.GenDecl, d comments.Comments) { 139 | // Decleration can be IMPORT, CONST, TYPE, VAR. We are only interested in VAR. 140 | if decl.Tok != token.VAR { 141 | return 142 | } 143 | d.Parse(decl.Doc) 144 | if d.Skip.Value { 145 | return 146 | } 147 | for _, spec := range decl.Specs { 148 | m.inspect(spec, d) 149 | } 150 | } 151 | 152 | func (m *Metadata) inspectValue(value *ast.ValueSpec, d comments.Comments) { 153 | d.Parse(value.Doc) 154 | if d.Skip.Value { 155 | return 156 | } 157 | for _, v := range value.Values { 158 | call, ok := v.(*ast.CallExpr) 159 | if !ok { 160 | continue 161 | } 162 | m.inspectCall(call, d) 163 | } 164 | } 165 | 166 | func (m *Metadata) inspectCall(call *ast.CallExpr, d comments.Comments) { 167 | selector, ok := call.Fun.(*ast.SelectorExpr) 168 | if !ok { 169 | return 170 | } 171 | 172 | // Full call name, of the form: 'package.Function'. 173 | fullName := name(selector.X) + "." + name(selector.Sel) 174 | 175 | switch fullName { 176 | default: 177 | return 178 | case "flag.String": 179 | checkNotSet(d.Default, "flag.String", "default") 180 | checkNotSet(d.Desc, "flag.String", "description") 181 | m.AddInput( 182 | unqoute(stringValue(call.Args[0])), 183 | Input{ 184 | Default: omitEmpty(unqoute(stringValue(call.Args[1]))), 185 | Desc: stringValue(call.Args[2]), 186 | Required: d.Required.Value, 187 | tp: inputFlag, 188 | }) 189 | case "flag.StringVar": 190 | checkNotSet(d.Default, "flag.StringVar", "default") 191 | checkNotSet(d.Desc, "flag.StringVar", "description") 192 | m.AddInput( 193 | unqoute(stringValue(call.Args[1])), 194 | Input{ 195 | Default: omitEmpty(unqoute(stringValue(call.Args[2]))), 196 | Desc: stringValue(call.Args[3]), 197 | Required: d.Required.Value, 198 | tp: inputFlag, 199 | }) 200 | case "flag.Int": 201 | checkNotSet(d.Default, "flag.Int", "default") 202 | checkNotSet(d.Desc, "flag.Int", "description") 203 | m.AddInput( 204 | unqoute(stringValue(call.Args[0])), 205 | Input{ 206 | Default: intValue(call.Args[1]), 207 | Desc: stringValue(call.Args[2]), 208 | Required: d.Required.Value, 209 | tp: inputFlag, 210 | }) 211 | case "flag.IntVar": 212 | checkNotSet(d.Default, "flag.IntVar", "default") 213 | checkNotSet(d.Desc, "flag.IntVar", "description") 214 | m.AddInput( 215 | unqoute(stringValue(call.Args[1])), 216 | Input{ 217 | Default: intValue(call.Args[2]), 218 | Desc: stringValue(call.Args[3]), 219 | Required: d.Required.Value, 220 | tp: inputFlag, 221 | }) 222 | case "flag.Bool": 223 | checkNotSet(d.Default, "flag.Bool", "default") 224 | checkNotSet(d.Desc, "flag.Bool", "description") 225 | m.AddInput( 226 | unqoute(stringValue(call.Args[0])), 227 | Input{ 228 | Default: boolValue(call.Args[1]), 229 | Desc: stringValue(call.Args[2]), 230 | Required: d.Required.Value, 231 | tp: inputFlag, 232 | }) 233 | case "flag.BoolVar": 234 | checkNotSet(d.Default, "flag.BoolVar", "default") 235 | checkNotSet(d.Desc, "flag.BoolVar", "description") 236 | m.AddInput( 237 | unqoute(stringValue(call.Args[1])), 238 | Input{ 239 | Default: boolValue(call.Args[2]), 240 | Desc: stringValue(call.Args[3]), 241 | Required: d.Required.Value, 242 | tp: inputFlag, 243 | }) 244 | case "os.Getenv": 245 | m.AddInput( 246 | unqoute(stringValue(call.Args[0])), 247 | Input{ 248 | Default: omitEmpty(d.Default.Value), 249 | Desc: d.Desc.Value, 250 | Required: d.Required.Value, 251 | tp: inputEnv, 252 | }) 253 | case "goaction.Output": 254 | checkNotSet(d.Default, "goaction.Output", "default") 255 | checkNotSet(d.Desc, "goaction.Output", "description") 256 | m.AddOutput( 257 | unqoute(stringValue(call.Args[0])), 258 | Output{ 259 | Desc: stringValue(call.Args[2]), 260 | }) 261 | } 262 | } 263 | 264 | func calcArgs(inputs yaml.MapSlice /* map[string]Input */) ([]string, error) { 265 | var args []string 266 | for _, mapItem := range inputs { 267 | name := mapItem.Key.(string) 268 | input := mapItem.Value.(Input) 269 | if input.tp != inputFlag { 270 | continue 271 | } 272 | args = append(args, fmt.Sprintf("\"-%s=${{ inputs.%s }}\"", name, name)) 273 | } 274 | return args, nil 275 | } 276 | 277 | func calcEnv(inputs yaml.MapSlice /* map[string]Input */) (yaml.MapSlice /* map[string]string */, error) { 278 | var envs yaml.MapSlice 279 | for _, mapItem := range inputs { 280 | name := mapItem.Key.(string) 281 | input := mapItem.Value.(Input) 282 | if input.tp != inputEnv { 283 | continue 284 | } 285 | envs = append(envs, yaml.MapItem{name, fmt.Sprintf("\"${{ inputs.%s }}\"", name)}) 286 | } 287 | return envs, nil 288 | } 289 | 290 | func stringValue(e ast.Expr) string { 291 | switch x := e.(type) { 292 | case *ast.BasicLit: 293 | return x.Value 294 | case *ast.Ident: 295 | if x.Name == "true" || x.Name == "false" { 296 | return x.Name 297 | } 298 | panic(ErrParse{error: fmt.Errorf("unsupported identifier: %v", x.Name), Pos: e.Pos()}) 299 | default: 300 | panic(ErrParse{error: fmt.Errorf("unsupported expression: %T", e), Pos: e.Pos()}) 301 | } 302 | } 303 | 304 | func intValue(e ast.Expr) int { 305 | v, err := strconv.Atoi(stringValue(e)) 306 | if err != nil { 307 | panic(ErrParse{error: err, Pos: e.Pos()}) 308 | } 309 | return v 310 | } 311 | 312 | func boolValue(e ast.Expr) bool { 313 | v, err := strconv.ParseBool(stringValue(e)) 314 | if err != nil { 315 | panic(ErrParse{error: err, Pos: e.Pos()}) 316 | } 317 | return v 318 | } 319 | 320 | func name(e ast.Expr) string { 321 | id, ok := e.(*ast.Ident) 322 | if !ok { 323 | return "" 324 | } 325 | return id.Name 326 | } 327 | 328 | func unqoute(s string) string { 329 | uq, err := strconv.Unquote(s) 330 | if err != nil { 331 | return s 332 | } 333 | return uq 334 | } 335 | 336 | func omitEmpty(s string) interface{} { 337 | if s == "" { 338 | return nil 339 | } 340 | return s 341 | } 342 | 343 | func checkNotSet(s comments.String, fnName, commentName string) { 344 | if s.Value != "" { 345 | panic(ErrParse{ 346 | Pos: s.Pos, 347 | error: fmt.Errorf("%s can't have %s annotation", fnName, commentName), 348 | }) 349 | } 350 | } 351 | -------------------------------------------------------------------------------- /goaction.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package goaction enables writing Github Actions in Go. 3 | 4 | The idea is: write a standard Go script, one that works with `go run`, and use it as Github action. 5 | The script's inputs - flags and environment variables, are set though the Github action API. This 6 | project will generate all the required files for the script (This generation can be done 7 | automattically with Github action integration). The library also exposes neat API to get workflow 8 | information. 9 | 10 | Required Steps 11 | 12 | - [x] Write a Go script. 13 | 14 | - [x] Add `goaction` configuration in `.github/workflows/goaction.yml`. 15 | 16 | - [x] Push the project to Github. 17 | 18 | See simplest example for a Goaction script: (posener/goaction-example) https://github.com/posener/goaction-example, 19 | or an example that demonstrait using Github APIs: (posener/goaction-issues-example) https://github.com/posener/goaction-issues-example. 20 | 21 | Writing a Goaction Script 22 | 23 | Write Github Action by writing Go code! Just start a Go module with a main package, and execute it 24 | as a Github action using Goaction, or from the command line using `go run`. 25 | 26 | A go executable can get inputs from the command line flag and from environment variables. Github 27 | actions should have a `action.yml` file that defines this API. Goaction bridges the gap by parsing 28 | the Go code and creating this file automatically for you. 29 | 30 | The main package inputs should be defined with the standard `flag` package for command line 31 | arguments, or by `os.Getenv` for environment variables. These inputs define the API of the program 32 | and `goaction` automatically detect them and creates the `action.yml` file from them. 33 | 34 | Additionally, goaction also provides a library that exposes all Github action environment in an 35 | easy-to-use API. See the documentation for more information. 36 | 37 | Code segments which should run only in Github action (called "CI mode"), and not when the main 38 | package runs as a command line tool, should be protected by a `if goaction.CI { ... }` block. 39 | 40 | Goaction Configuration 41 | 42 | In order to convert the repository to a Github action, goaction command line should run on the 43 | **"main file"** (described above). This command can run manually (by ./cmd/goaction) but luckily 44 | `goaction` also comes as a Github action :-) 45 | 46 | Goaction Github action keeps the Github action file updated according to the main Go file 47 | automatically. When a PR is made, goaction will post a review explaining what changes to expect. 48 | When a new commit is pushed, Goaction makes sure that the Github action files are updated if needed. 49 | 50 | Add the following content to `.github/workflows/goaction.yml` 51 | 52 | on: 53 | pull_request: 54 | branches: [main] 55 | push: 56 | branches: [main] 57 | permissions: 58 | # Goaction needs permissions to update pull requests comments and update contents. 59 | pull-requests: write 60 | contents: write 61 | jobs: 62 | goaction: 63 | runs-on: ubuntu-latest 64 | steps: 65 | - name: Check out repository 66 | uses: actions/checkout@v2 67 | - name: Update action files 68 | uses: posener/goaction@v1 69 | with: 70 | # Optional: required only for commenting on PRs. 71 | github-token: '${{ secrets.GITHUB_TOKEN }}' 72 | # Optional: now that the script is a Github action, it is possible to run it in the 73 | # workflow. 74 | - name: Example 75 | uses: ./ 76 | 77 | Goaction Artifacts 78 | 79 | ./action.yml: A "metadata" file for Github actions. If this file exists, the repository is 80 | considered as Github action, and the file contains information that instructs how to invoke this 81 | action. See (metadata syntax) https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions. 82 | for more info. 83 | 84 | ./Dockerfile: A file that contains instructions how to build a container, that is used for Github 85 | actions. Github action uses this file in order to create a container image to the action. The 86 | container can also be built and tested manually: 87 | 88 | $ docker build -t my-action . 89 | $ docker run --rm my-action 90 | 91 | Annotations 92 | 93 | Goaction parses Go script file and looks for annotations that extends the information that exists in 94 | the function calls. Goaction annotations are a comments that start with `//goaction:` (no space 95 | after slashes). They can only be set on a `var` definition. The following annotations are available: 96 | 97 | * `//goaction:required` - sets an input definition to be "required". 98 | 99 | * `//goaction:skip` - skips an input out output definition. 100 | 101 | * `//goaction:description ` - add description for `os.Getenv`. 102 | 103 | * `//goaction:default ` - add default value for `os.Getenv`. 104 | 105 | Using Goaction 106 | 107 | A list of projects which are using Goaction (please send a PR if your project uses goaction and does 108 | not appear her). 109 | 110 | * (posener/goreadme) http://github.com/posener/goreadme 111 | 112 | */ 113 | package goaction 114 | 115 | import ( 116 | "fmt" 117 | "log" 118 | "os" 119 | "strconv" 120 | "strings" 121 | ) 122 | 123 | // Github actions default environment variables. 124 | // See https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables 125 | var ( 126 | // CI is set to true when running under github action 127 | // 128 | // This variable can be used to protect code segments which should only run in Github action 129 | // mode and not in command line mode: 130 | // 131 | // if goaction.CI { 132 | // // Code that should run only in Github action mode. 133 | // } 134 | CI = os.Getenv("CI") == "true" 135 | // The path to the GitHub home directory used to store user data. For example, /github/home. 136 | Home = os.Getenv("HOME") 137 | // The name of the workflow 138 | Workflow = os.Getenv("GITHUB_WORKFLOW") 139 | // A unique number for each run within a repository. This number does not change if you re-run 140 | // the workflow run. 141 | RunID = os.Getenv("GITHUB_RUN_ID") 142 | // A unique number for each run of a particular workflow in a repository. This number begins at 143 | // 1 for the workflow's first run, and increments with each new run. This number does not change 144 | // if you re-run the workflow run. 145 | RunNum = os.Getenv("GITHUB_RUN_NUMBER") 146 | // The unique identifier (id) of the action. 147 | ActionID = os.Getenv("GITHUB_ACTION") 148 | // The name of the person or app that initiated the workflow. For example, octocat. 149 | Actor = os.Getenv("GITHUB_ACTOR") 150 | // The owner and repository name. For example, octocat/Hello-World. 151 | Repository = os.Getenv("GITHUB_REPOSITORY") 152 | // The name of the webhook event that triggered the workflow. 153 | Event = EventType(os.Getenv("GITHUB_EVENT_NAME")) 154 | // The GitHub workspace directory path. The workspace directory contains a subdirectory with a 155 | // copy of your repository if your workflow uses the actions/checkout action. If you don't use 156 | // the actions/checkout action, the directory will be empty. For example, 157 | // /home/runner/work/my-repo-name/my-repo-name. 158 | Workspace = os.Getenv("GITHUB_WORKSPACE") 159 | // The commit SHA that triggered the workflow. For example, 160 | // ffac537e6cbbf934b08745a378932722df287a53. 161 | SHA = os.Getenv("GITHUB_SHA") 162 | // The branch or tag ref that triggered the workflow. For example, refs/heads/feature-branch-1. 163 | // If neither a branch or tag is available for the event type, the variable will not exist. 164 | Ref = os.Getenv("GITHUB_REF") 165 | // Only set for forked repositories. The branch of the head repository. 166 | ForkedHeadRef = os.Getenv("GITHUB_HEAD_REF") 167 | // Only set for forked repositories. The branch of the base repository. 168 | ForkedBaseRef = os.Getenv("GITHUB_BASE_REF") 169 | 170 | eventPath = os.Getenv("GITHUB_EVENT_PATH") 171 | envPath = os.Getenv("GITHUB_ENV") 172 | 173 | repoParts = strings.Split(Repository, "/") 174 | ) 175 | 176 | func init() { 177 | if CI { 178 | // Set the default logging to stdout since Github actions treats stderr as error level logs. 179 | log.SetOutput(os.Stdout) 180 | } 181 | } 182 | 183 | // Setenv sets an environment variable that will only be visible for all following Github actions in 184 | // the current workflow, but not in the current action. 185 | // See https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#environment-files. 186 | func Setenv(name string, value string) error { 187 | if !CI { 188 | return nil 189 | } 190 | // Store in the given environment variable name such that programs that expect this environment 191 | // variable (not through goaction) can get it. 192 | f, err := os.OpenFile(envPath, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0) 193 | if err != nil { 194 | return fmt.Errorf("can't open env file %s: %s", envPath, err) 195 | } 196 | defer f.Close() 197 | _, err = fmt.Fprintf(f, "%s=%s\n", name, value) 198 | if err != nil { 199 | return fmt.Errorf("failed writing to env file: %s", err) 200 | } 201 | return nil 202 | } 203 | 204 | // Export sets an environment variable that will also be visible for all following Github actions in 205 | // the current workflow. 206 | func Export(name string, value string) error { 207 | err := os.Setenv(name, value) 208 | if err != nil { 209 | return err 210 | } 211 | return Setenv(name, value) 212 | } 213 | 214 | // Output sets Github action output. 215 | // See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter. 216 | func Output(name string, value string, desc string) { 217 | if !CI { 218 | return 219 | } 220 | fmt.Printf("::set-output name=%s::%s\n", name, value) 221 | } 222 | 223 | // AddPath prepends a directory to the system PATH variable for all subsequent actions in the 224 | // current job. The currently running action cannot access the new path variable. 225 | // See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path. 226 | func AddPath(path string) { 227 | if !CI { 228 | return 229 | } 230 | fmt.Printf("::add-path::%s\n", path) 231 | } 232 | 233 | // Owner returns the name of the owner of the Github repository. 234 | func Owner() string { 235 | if len(repoParts) < 2 { 236 | return "" 237 | } 238 | return repoParts[0] 239 | } 240 | 241 | // Project returns the name of the project of the Github repository. 242 | func Project() string { 243 | if len(repoParts) < 2 { 244 | return "" 245 | } 246 | return repoParts[1] 247 | } 248 | 249 | // Branch returns the push branch for push flow or empty string for other flows. 250 | func Branch() string { 251 | return strings.Split(Ref, "/")[2] 252 | } 253 | 254 | // PrNum returns pull request number for PR flow or -1 in other flows. 255 | func PrNum() int { 256 | if Event == EventPullRequest { 257 | // Ref is in the form: "refs/pull/:prNumber/merge" 258 | // See https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request 259 | num, err := strconv.Atoi(strings.Split(Ref, "/")[2]) 260 | if err != nil { 261 | panic(err) // Should not happen 262 | } 263 | return num 264 | } 265 | return -1 266 | } 267 | 268 | // IsForked return true if the action is running on a forked repository. 269 | func IsForked() bool { 270 | return ForkedBaseRef != "" 271 | } 272 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /actionutil/githubapi.go: -------------------------------------------------------------------------------- 1 | // Autogenerated by go run internal/genapi/main.go. DO NOT EDIT. 2 | 3 | package actionutil 4 | 5 | import ( 6 | "context" 7 | "io" 8 | "net/http" 9 | "net/url" 10 | "os" 11 | "time" 12 | 13 | "github.com/google/go-github/v31/github" 14 | "github.com/posener/goaction" 15 | "golang.org/x/oauth2" 16 | ) 17 | 18 | // Client is a small wrapper around github.Client, that does not require to repeatedly type the 19 | // owner and repository in various function calls. 20 | type Client struct { 21 | *github.Client 22 | Owner string 23 | Project string 24 | } 25 | 26 | // NewClient returns a github client. 27 | func NewClient(c *http.Client) *Client { 28 | return &Client{ 29 | Client: github.NewClient(c), 30 | Owner: goaction.Owner(), 31 | Project: goaction.Project(), 32 | } 33 | } 34 | 35 | // NewClientWithToken returns a github client from a given auth token, according to 36 | // https://github.com/google/go-github#authentication. 37 | func NewClientWithToken(ctx context.Context, token string) *Client { 38 | ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) 39 | return NewClient(oauth2.NewClient(ctx, ts)) 40 | } 41 | 42 | // ActionsListWorkflowRunArtifacts calls the Actions.ListWorkflowRunArtifacts method with 43 | // the relevant owner and repo arguments. 44 | func (c *Client) ActionsListWorkflowRunArtifacts(ctx context.Context, runID int64, opts *github.ListOptions) (*github.ArtifactList, *github.Response, error) { 45 | return c.Actions.ListWorkflowRunArtifacts(ctx, c.Owner, c.Project, runID, opts) 46 | } 47 | 48 | // ActionsGetArtifact calls the Actions.GetArtifact method with 49 | // the relevant owner and repo arguments. 50 | func (c *Client) ActionsGetArtifact(ctx context.Context, artifactID int64) (*github.Artifact, *github.Response, error) { 51 | return c.Actions.GetArtifact(ctx, c.Owner, c.Project, artifactID) 52 | } 53 | 54 | // ActionsDownloadArtifact calls the Actions.DownloadArtifact method with 55 | // the relevant owner and repo arguments. 56 | func (c *Client) ActionsDownloadArtifact(ctx context.Context, artifactID int64, followRedirects bool) (*url.URL, *github.Response, error) { 57 | return c.Actions.DownloadArtifact(ctx, c.Owner, c.Project, artifactID, followRedirects) 58 | } 59 | 60 | // ActionsDeleteArtifact calls the Actions.DeleteArtifact method with 61 | // the relevant owner and repo arguments. 62 | func (c *Client) ActionsDeleteArtifact(ctx context.Context, artifactID int64) (*github.Response, error) { 63 | return c.Actions.DeleteArtifact(ctx, c.Owner, c.Project, artifactID) 64 | } 65 | 66 | // ActionsListRunnerApplicationDownloads calls the Actions.ListRunnerApplicationDownloads method with 67 | // the relevant owner and repo arguments. 68 | func (c *Client) ActionsListRunnerApplicationDownloads(ctx context.Context) ([]*github.RunnerApplicationDownload, *github.Response, error) { 69 | return c.Actions.ListRunnerApplicationDownloads(ctx, c.Owner, c.Project) 70 | } 71 | 72 | // ActionsCreateRegistrationToken calls the Actions.CreateRegistrationToken method with 73 | // the relevant owner and repo arguments. 74 | func (c *Client) ActionsCreateRegistrationToken(ctx context.Context) (*github.RegistrationToken, *github.Response, error) { 75 | return c.Actions.CreateRegistrationToken(ctx, c.Owner, c.Project) 76 | } 77 | 78 | // ActionsListRunners calls the Actions.ListRunners method with 79 | // the relevant owner and repo arguments. 80 | func (c *Client) ActionsListRunners(ctx context.Context, opts *github.ListOptions) (*github.Runners, *github.Response, error) { 81 | return c.Actions.ListRunners(ctx, c.Owner, c.Project, opts) 82 | } 83 | 84 | // ActionsGetRunner calls the Actions.GetRunner method with 85 | // the relevant owner and repo arguments. 86 | func (c *Client) ActionsGetRunner(ctx context.Context, runnerID int64) (*github.Runner, *github.Response, error) { 87 | return c.Actions.GetRunner(ctx, c.Owner, c.Project, runnerID) 88 | } 89 | 90 | // ActionsCreateRemoveToken calls the Actions.CreateRemoveToken method with 91 | // the relevant owner and repo arguments. 92 | func (c *Client) ActionsCreateRemoveToken(ctx context.Context) (*github.RemoveToken, *github.Response, error) { 93 | return c.Actions.CreateRemoveToken(ctx, c.Owner, c.Project) 94 | } 95 | 96 | // ActionsRemoveRunner calls the Actions.RemoveRunner method with 97 | // the relevant owner and repo arguments. 98 | func (c *Client) ActionsRemoveRunner(ctx context.Context, runnerID int64) (*github.Response, error) { 99 | return c.Actions.RemoveRunner(ctx, c.Owner, c.Project, runnerID) 100 | } 101 | 102 | // ActionsGetPublicKey calls the Actions.GetPublicKey method with 103 | // the relevant owner and repo arguments. 104 | func (c *Client) ActionsGetPublicKey(ctx context.Context) (*github.PublicKey, *github.Response, error) { 105 | return c.Actions.GetPublicKey(ctx, c.Owner, c.Project) 106 | } 107 | 108 | // ActionsListSecrets calls the Actions.ListSecrets method with 109 | // the relevant owner and repo arguments. 110 | func (c *Client) ActionsListSecrets(ctx context.Context, opts *github.ListOptions) (*github.Secrets, *github.Response, error) { 111 | return c.Actions.ListSecrets(ctx, c.Owner, c.Project, opts) 112 | } 113 | 114 | // ActionsGetSecret calls the Actions.GetSecret method with 115 | // the relevant owner and repo arguments. 116 | func (c *Client) ActionsGetSecret(ctx context.Context, name string) (*github.Secret, *github.Response, error) { 117 | return c.Actions.GetSecret(ctx, c.Owner, c.Project, name) 118 | } 119 | 120 | // ActionsCreateOrUpdateSecret calls the Actions.CreateOrUpdateSecret method with 121 | // the relevant owner and repo arguments. 122 | func (c *Client) ActionsCreateOrUpdateSecret(ctx context.Context, eSecret *github.EncryptedSecret) (*github.Response, error) { 123 | return c.Actions.CreateOrUpdateSecret(ctx, c.Owner, c.Project, eSecret) 124 | } 125 | 126 | // ActionsDeleteSecret calls the Actions.DeleteSecret method with 127 | // the relevant owner and repo arguments. 128 | func (c *Client) ActionsDeleteSecret(ctx context.Context, name string) (*github.Response, error) { 129 | return c.Actions.DeleteSecret(ctx, c.Owner, c.Project, name) 130 | } 131 | 132 | // ActionsListWorkflowJobs calls the Actions.ListWorkflowJobs method with 133 | // the relevant owner and repo arguments. 134 | func (c *Client) ActionsListWorkflowJobs(ctx context.Context, runID int64, opts *github.ListWorkflowJobsOptions) (*github.Jobs, *github.Response, error) { 135 | return c.Actions.ListWorkflowJobs(ctx, c.Owner, c.Project, runID, opts) 136 | } 137 | 138 | // ActionsGetWorkflowJobByID calls the Actions.GetWorkflowJobByID method with 139 | // the relevant owner and repo arguments. 140 | func (c *Client) ActionsGetWorkflowJobByID(ctx context.Context, jobID int64) (*github.WorkflowJob, *github.Response, error) { 141 | return c.Actions.GetWorkflowJobByID(ctx, c.Owner, c.Project, jobID) 142 | } 143 | 144 | // ActionsGetWorkflowJobLogs calls the Actions.GetWorkflowJobLogs method with 145 | // the relevant owner and repo arguments. 146 | func (c *Client) ActionsGetWorkflowJobLogs(ctx context.Context, jobID int64, followRedirects bool) (*url.URL, *github.Response, error) { 147 | return c.Actions.GetWorkflowJobLogs(ctx, c.Owner, c.Project, jobID, followRedirects) 148 | } 149 | 150 | // ActionsListWorkflowRunsByID calls the Actions.ListWorkflowRunsByID method with 151 | // the relevant owner and repo arguments. 152 | func (c *Client) ActionsListWorkflowRunsByID(ctx context.Context, workflowID int64, opts *github.ListWorkflowRunsOptions) (*github.WorkflowRuns, *github.Response, error) { 153 | return c.Actions.ListWorkflowRunsByID(ctx, c.Owner, c.Project, workflowID, opts) 154 | } 155 | 156 | // ActionsListWorkflowRunsByFileName calls the Actions.ListWorkflowRunsByFileName method with 157 | // the relevant owner and repo arguments. 158 | func (c *Client) ActionsListWorkflowRunsByFileName(ctx context.Context, workflowFileName string, opts *github.ListWorkflowRunsOptions) (*github.WorkflowRuns, *github.Response, error) { 159 | return c.Actions.ListWorkflowRunsByFileName(ctx, c.Owner, c.Project, workflowFileName, opts) 160 | } 161 | 162 | // ActionsListRepositoryWorkflowRuns calls the Actions.ListRepositoryWorkflowRuns method with 163 | // the relevant owner and repo arguments. 164 | func (c *Client) ActionsListRepositoryWorkflowRuns(ctx context.Context, opts *github.ListOptions) (*github.WorkflowRuns, *github.Response, error) { 165 | return c.Actions.ListRepositoryWorkflowRuns(ctx, c.Owner, c.Project, opts) 166 | } 167 | 168 | // ActionsGetWorkflowRunByID calls the Actions.GetWorkflowRunByID method with 169 | // the relevant owner and repo arguments. 170 | func (c *Client) ActionsGetWorkflowRunByID(ctx context.Context, runID int64) (*github.WorkflowRun, *github.Response, error) { 171 | return c.Actions.GetWorkflowRunByID(ctx, c.Owner, c.Project, runID) 172 | } 173 | 174 | // ActionsRerunWorkflowByID calls the Actions.RerunWorkflowByID method with 175 | // the relevant owner and repo arguments. 176 | func (c *Client) ActionsRerunWorkflowByID(ctx context.Context, runID int64) (*github.Response, error) { 177 | return c.Actions.RerunWorkflowByID(ctx, c.Owner, c.Project, runID) 178 | } 179 | 180 | // ActionsCancelWorkflowRunByID calls the Actions.CancelWorkflowRunByID method with 181 | // the relevant owner and repo arguments. 182 | func (c *Client) ActionsCancelWorkflowRunByID(ctx context.Context, runID int64) (*github.Response, error) { 183 | return c.Actions.CancelWorkflowRunByID(ctx, c.Owner, c.Project, runID) 184 | } 185 | 186 | // ActionsGetWorkflowRunLogs calls the Actions.GetWorkflowRunLogs method with 187 | // the relevant owner and repo arguments. 188 | func (c *Client) ActionsGetWorkflowRunLogs(ctx context.Context, runID int64, followRedirects bool) (*url.URL, *github.Response, error) { 189 | return c.Actions.GetWorkflowRunLogs(ctx, c.Owner, c.Project, runID, followRedirects) 190 | } 191 | 192 | // ActionsListWorkflows calls the Actions.ListWorkflows method with 193 | // the relevant owner and repo arguments. 194 | func (c *Client) ActionsListWorkflows(ctx context.Context, opts *github.ListOptions) (*github.Workflows, *github.Response, error) { 195 | return c.Actions.ListWorkflows(ctx, c.Owner, c.Project, opts) 196 | } 197 | 198 | // ActionsGetWorkflowByID calls the Actions.GetWorkflowByID method with 199 | // the relevant owner and repo arguments. 200 | func (c *Client) ActionsGetWorkflowByID(ctx context.Context, workflowID int64) (*github.Workflow, *github.Response, error) { 201 | return c.Actions.GetWorkflowByID(ctx, c.Owner, c.Project, workflowID) 202 | } 203 | 204 | // ActionsGetWorkflowByFileName calls the Actions.GetWorkflowByFileName method with 205 | // the relevant owner and repo arguments. 206 | func (c *Client) ActionsGetWorkflowByFileName(ctx context.Context, workflowFileName string) (*github.Workflow, *github.Response, error) { 207 | return c.Actions.GetWorkflowByFileName(ctx, c.Owner, c.Project, workflowFileName) 208 | } 209 | 210 | // ActivityListRepositoryEvents calls the Activity.ListRepositoryEvents method with 211 | // the relevant owner and repo arguments. 212 | func (c *Client) ActivityListRepositoryEvents(ctx context.Context, opts *github.ListOptions) ([]*github.Event, *github.Response, error) { 213 | return c.Activity.ListRepositoryEvents(ctx, c.Owner, c.Project, opts) 214 | } 215 | 216 | // ActivityListIssueEventsForRepository calls the Activity.ListIssueEventsForRepository method with 217 | // the relevant owner and repo arguments. 218 | func (c *Client) ActivityListIssueEventsForRepository(ctx context.Context, opts *github.ListOptions) ([]*github.IssueEvent, *github.Response, error) { 219 | return c.Activity.ListIssueEventsForRepository(ctx, c.Owner, c.Project, opts) 220 | } 221 | 222 | // ActivityListEventsForRepoNetwork calls the Activity.ListEventsForRepoNetwork method with 223 | // the relevant owner and repo arguments. 224 | func (c *Client) ActivityListEventsForRepoNetwork(ctx context.Context, opts *github.ListOptions) ([]*github.Event, *github.Response, error) { 225 | return c.Activity.ListEventsForRepoNetwork(ctx, c.Owner, c.Project, opts) 226 | } 227 | 228 | // ActivityListRepositoryNotifications calls the Activity.ListRepositoryNotifications method with 229 | // the relevant owner and repo arguments. 230 | func (c *Client) ActivityListRepositoryNotifications(ctx context.Context, opts *github.NotificationListOptions) ([]*github.Notification, *github.Response, error) { 231 | return c.Activity.ListRepositoryNotifications(ctx, c.Owner, c.Project, opts) 232 | } 233 | 234 | // ActivityMarkRepositoryNotificationsRead calls the Activity.MarkRepositoryNotificationsRead method with 235 | // the relevant owner and repo arguments. 236 | func (c *Client) ActivityMarkRepositoryNotificationsRead(ctx context.Context, lastRead time.Time) (*github.Response, error) { 237 | return c.Activity.MarkRepositoryNotificationsRead(ctx, c.Owner, c.Project, lastRead) 238 | } 239 | 240 | // ActivityListStargazers calls the Activity.ListStargazers method with 241 | // the relevant owner and repo arguments. 242 | func (c *Client) ActivityListStargazers(ctx context.Context, opts *github.ListOptions) ([]*github.Stargazer, *github.Response, error) { 243 | return c.Activity.ListStargazers(ctx, c.Owner, c.Project, opts) 244 | } 245 | 246 | // ActivityIsStarred calls the Activity.IsStarred method with 247 | // the relevant owner and repo arguments. 248 | func (c *Client) ActivityIsStarred(ctx context.Context) (bool, *github.Response, error) { 249 | return c.Activity.IsStarred(ctx, c.Owner, c.Project) 250 | } 251 | 252 | // ActivityStar calls the Activity.Star method with 253 | // the relevant owner and repo arguments. 254 | func (c *Client) ActivityStar(ctx context.Context) (*github.Response, error) { 255 | return c.Activity.Star(ctx, c.Owner, c.Project) 256 | } 257 | 258 | // ActivityUnstar calls the Activity.Unstar method with 259 | // the relevant owner and repo arguments. 260 | func (c *Client) ActivityUnstar(ctx context.Context) (*github.Response, error) { 261 | return c.Activity.Unstar(ctx, c.Owner, c.Project) 262 | } 263 | 264 | // ActivityListWatchers calls the Activity.ListWatchers method with 265 | // the relevant owner and repo arguments. 266 | func (c *Client) ActivityListWatchers(ctx context.Context, opts *github.ListOptions) ([]*github.User, *github.Response, error) { 267 | return c.Activity.ListWatchers(ctx, c.Owner, c.Project, opts) 268 | } 269 | 270 | // ActivityGetRepositorySubscription calls the Activity.GetRepositorySubscription method with 271 | // the relevant owner and repo arguments. 272 | func (c *Client) ActivityGetRepositorySubscription(ctx context.Context) (*github.Subscription, *github.Response, error) { 273 | return c.Activity.GetRepositorySubscription(ctx, c.Owner, c.Project) 274 | } 275 | 276 | // ActivitySetRepositorySubscription calls the Activity.SetRepositorySubscription method with 277 | // the relevant owner and repo arguments. 278 | func (c *Client) ActivitySetRepositorySubscription(ctx context.Context, subscription *github.Subscription) (*github.Subscription, *github.Response, error) { 279 | return c.Activity.SetRepositorySubscription(ctx, c.Owner, c.Project, subscription) 280 | } 281 | 282 | // ActivityDeleteRepositorySubscription calls the Activity.DeleteRepositorySubscription method with 283 | // the relevant owner and repo arguments. 284 | func (c *Client) ActivityDeleteRepositorySubscription(ctx context.Context) (*github.Response, error) { 285 | return c.Activity.DeleteRepositorySubscription(ctx, c.Owner, c.Project) 286 | } 287 | 288 | // AppsFindRepositoryInstallation calls the Apps.FindRepositoryInstallation method with 289 | // the relevant owner and repo arguments. 290 | func (c *Client) AppsFindRepositoryInstallation(ctx context.Context) (*github.Installation, *github.Response, error) { 291 | return c.Apps.FindRepositoryInstallation(ctx, c.Owner, c.Project) 292 | } 293 | 294 | // ChecksGetCheckRun calls the Checks.GetCheckRun method with 295 | // the relevant owner and repo arguments. 296 | func (c *Client) ChecksGetCheckRun(ctx context.Context, checkRunID int64) (*github.CheckRun, *github.Response, error) { 297 | return c.Checks.GetCheckRun(ctx, c.Owner, c.Project, checkRunID) 298 | } 299 | 300 | // ChecksGetCheckSuite calls the Checks.GetCheckSuite method with 301 | // the relevant owner and repo arguments. 302 | func (c *Client) ChecksGetCheckSuite(ctx context.Context, checkSuiteID int64) (*github.CheckSuite, *github.Response, error) { 303 | return c.Checks.GetCheckSuite(ctx, c.Owner, c.Project, checkSuiteID) 304 | } 305 | 306 | // ChecksCreateCheckRun calls the Checks.CreateCheckRun method with 307 | // the relevant owner and repo arguments. 308 | func (c *Client) ChecksCreateCheckRun(ctx context.Context, opts github.CreateCheckRunOptions) (*github.CheckRun, *github.Response, error) { 309 | return c.Checks.CreateCheckRun(ctx, c.Owner, c.Project, opts) 310 | } 311 | 312 | // ChecksUpdateCheckRun calls the Checks.UpdateCheckRun method with 313 | // the relevant owner and repo arguments. 314 | func (c *Client) ChecksUpdateCheckRun(ctx context.Context, checkRunID int64, opts github.UpdateCheckRunOptions) (*github.CheckRun, *github.Response, error) { 315 | return c.Checks.UpdateCheckRun(ctx, c.Owner, c.Project, checkRunID, opts) 316 | } 317 | 318 | // ChecksListCheckRunAnnotations calls the Checks.ListCheckRunAnnotations method with 319 | // the relevant owner and repo arguments. 320 | func (c *Client) ChecksListCheckRunAnnotations(ctx context.Context, checkRunID int64, opts *github.ListOptions) ([]*github.CheckRunAnnotation, *github.Response, error) { 321 | return c.Checks.ListCheckRunAnnotations(ctx, c.Owner, c.Project, checkRunID, opts) 322 | } 323 | 324 | // ChecksListCheckRunsForRef calls the Checks.ListCheckRunsForRef method with 325 | // the relevant owner and repo arguments. 326 | func (c *Client) ChecksListCheckRunsForRef(ctx context.Context, ref string, opts *github.ListCheckRunsOptions) (*github.ListCheckRunsResults, *github.Response, error) { 327 | return c.Checks.ListCheckRunsForRef(ctx, c.Owner, c.Project, ref, opts) 328 | } 329 | 330 | // ChecksListCheckRunsCheckSuite calls the Checks.ListCheckRunsCheckSuite method with 331 | // the relevant owner and repo arguments. 332 | func (c *Client) ChecksListCheckRunsCheckSuite(ctx context.Context, checkSuiteID int64, opts *github.ListCheckRunsOptions) (*github.ListCheckRunsResults, *github.Response, error) { 333 | return c.Checks.ListCheckRunsCheckSuite(ctx, c.Owner, c.Project, checkSuiteID, opts) 334 | } 335 | 336 | // ChecksListCheckSuitesForRef calls the Checks.ListCheckSuitesForRef method with 337 | // the relevant owner and repo arguments. 338 | func (c *Client) ChecksListCheckSuitesForRef(ctx context.Context, ref string, opts *github.ListCheckSuiteOptions) (*github.ListCheckSuiteResults, *github.Response, error) { 339 | return c.Checks.ListCheckSuitesForRef(ctx, c.Owner, c.Project, ref, opts) 340 | } 341 | 342 | // ChecksSetCheckSuitePreferences calls the Checks.SetCheckSuitePreferences method with 343 | // the relevant owner and repo arguments. 344 | func (c *Client) ChecksSetCheckSuitePreferences(ctx context.Context, opts github.CheckSuitePreferenceOptions) (*github.CheckSuitePreferenceResults, *github.Response, error) { 345 | return c.Checks.SetCheckSuitePreferences(ctx, c.Owner, c.Project, opts) 346 | } 347 | 348 | // ChecksCreateCheckSuite calls the Checks.CreateCheckSuite method with 349 | // the relevant owner and repo arguments. 350 | func (c *Client) ChecksCreateCheckSuite(ctx context.Context, opts github.CreateCheckSuiteOptions) (*github.CheckSuite, *github.Response, error) { 351 | return c.Checks.CreateCheckSuite(ctx, c.Owner, c.Project, opts) 352 | } 353 | 354 | // ChecksReRequestCheckSuite calls the Checks.ReRequestCheckSuite method with 355 | // the relevant owner and repo arguments. 356 | func (c *Client) ChecksReRequestCheckSuite(ctx context.Context, checkSuiteID int64) (*github.Response, error) { 357 | return c.Checks.ReRequestCheckSuite(ctx, c.Owner, c.Project, checkSuiteID) 358 | } 359 | 360 | // GitGetBlob calls the Git.GetBlob method with 361 | // the relevant owner and repo arguments. 362 | func (c *Client) GitGetBlob(ctx context.Context, sha string) (*github.Blob, *github.Response, error) { 363 | return c.Git.GetBlob(ctx, c.Owner, c.Project, sha) 364 | } 365 | 366 | // GitGetBlobRaw calls the Git.GetBlobRaw method with 367 | // the relevant owner and repo arguments. 368 | func (c *Client) GitGetBlobRaw(ctx context.Context, sha string) ([]byte, *github.Response, error) { 369 | return c.Git.GetBlobRaw(ctx, c.Owner, c.Project, sha) 370 | } 371 | 372 | // GitCreateBlob calls the Git.CreateBlob method with 373 | // the relevant owner and repo arguments. 374 | func (c *Client) GitCreateBlob(ctx context.Context, blob *github.Blob) (*github.Blob, *github.Response, error) { 375 | return c.Git.CreateBlob(ctx, c.Owner, c.Project, blob) 376 | } 377 | 378 | // GitGetCommit calls the Git.GetCommit method with 379 | // the relevant owner and repo arguments. 380 | func (c *Client) GitGetCommit(ctx context.Context, sha string) (*github.Commit, *github.Response, error) { 381 | return c.Git.GetCommit(ctx, c.Owner, c.Project, sha) 382 | } 383 | 384 | // GitCreateCommit calls the Git.CreateCommit method with 385 | // the relevant owner and repo arguments. 386 | func (c *Client) GitCreateCommit(ctx context.Context, commit *github.Commit) (*github.Commit, *github.Response, error) { 387 | return c.Git.CreateCommit(ctx, c.Owner, c.Project, commit) 388 | } 389 | 390 | // GitGetRef calls the Git.GetRef method with 391 | // the relevant owner and repo arguments. 392 | func (c *Client) GitGetRef(ctx context.Context, ref string) (*github.Reference, *github.Response, error) { 393 | return c.Git.GetRef(ctx, c.Owner, c.Project, ref) 394 | } 395 | 396 | // GitGetRefs calls the Git.GetRefs method with 397 | // the relevant owner and repo arguments. 398 | func (c *Client) GitGetRefs(ctx context.Context, ref string) ([]*github.Reference, *github.Response, error) { 399 | return c.Git.GetRefs(ctx, c.Owner, c.Project, ref) 400 | } 401 | 402 | // GitListRefs calls the Git.ListRefs method with 403 | // the relevant owner and repo arguments. 404 | func (c *Client) GitListRefs(ctx context.Context, opts *github.ReferenceListOptions) ([]*github.Reference, *github.Response, error) { 405 | return c.Git.ListRefs(ctx, c.Owner, c.Project, opts) 406 | } 407 | 408 | // GitCreateRef calls the Git.CreateRef method with 409 | // the relevant owner and repo arguments. 410 | func (c *Client) GitCreateRef(ctx context.Context, ref *github.Reference) (*github.Reference, *github.Response, error) { 411 | return c.Git.CreateRef(ctx, c.Owner, c.Project, ref) 412 | } 413 | 414 | // GitUpdateRef calls the Git.UpdateRef method with 415 | // the relevant owner and repo arguments. 416 | func (c *Client) GitUpdateRef(ctx context.Context, ref *github.Reference, force bool) (*github.Reference, *github.Response, error) { 417 | return c.Git.UpdateRef(ctx, c.Owner, c.Project, ref, force) 418 | } 419 | 420 | // GitDeleteRef calls the Git.DeleteRef method with 421 | // the relevant owner and repo arguments. 422 | func (c *Client) GitDeleteRef(ctx context.Context, ref string) (*github.Response, error) { 423 | return c.Git.DeleteRef(ctx, c.Owner, c.Project, ref) 424 | } 425 | 426 | // GitGetTag calls the Git.GetTag method with 427 | // the relevant owner and repo arguments. 428 | func (c *Client) GitGetTag(ctx context.Context, sha string) (*github.Tag, *github.Response, error) { 429 | return c.Git.GetTag(ctx, c.Owner, c.Project, sha) 430 | } 431 | 432 | // GitCreateTag calls the Git.CreateTag method with 433 | // the relevant owner and repo arguments. 434 | func (c *Client) GitCreateTag(ctx context.Context, tag *github.Tag) (*github.Tag, *github.Response, error) { 435 | return c.Git.CreateTag(ctx, c.Owner, c.Project, tag) 436 | } 437 | 438 | // GitGetTree calls the Git.GetTree method with 439 | // the relevant owner and repo arguments. 440 | func (c *Client) GitGetTree(ctx context.Context, sha string, recursive bool) (*github.Tree, *github.Response, error) { 441 | return c.Git.GetTree(ctx, c.Owner, c.Project, sha, recursive) 442 | } 443 | 444 | // GitCreateTree calls the Git.CreateTree method with 445 | // the relevant owner and repo arguments. 446 | func (c *Client) GitCreateTree(ctx context.Context, baseTree string, entries []*github.TreeEntry) (*github.Tree, *github.Response, error) { 447 | return c.Git.CreateTree(ctx, c.Owner, c.Project, baseTree, entries) 448 | } 449 | 450 | // InteractionsGetRestrictionsForRepo calls the Interactions.GetRestrictionsForRepo method with 451 | // the relevant owner and repo arguments. 452 | func (c *Client) InteractionsGetRestrictionsForRepo(ctx context.Context) (*github.InteractionRestriction, *github.Response, error) { 453 | return c.Interactions.GetRestrictionsForRepo(ctx, c.Owner, c.Project) 454 | } 455 | 456 | // InteractionsUpdateRestrictionsForRepo calls the Interactions.UpdateRestrictionsForRepo method with 457 | // the relevant owner and repo arguments. 458 | func (c *Client) InteractionsUpdateRestrictionsForRepo(ctx context.Context, limit string) (*github.InteractionRestriction, *github.Response, error) { 459 | return c.Interactions.UpdateRestrictionsForRepo(ctx, c.Owner, c.Project, limit) 460 | } 461 | 462 | // InteractionsRemoveRestrictionsFromRepo calls the Interactions.RemoveRestrictionsFromRepo method with 463 | // the relevant owner and repo arguments. 464 | func (c *Client) InteractionsRemoveRestrictionsFromRepo(ctx context.Context) (*github.Response, error) { 465 | return c.Interactions.RemoveRestrictionsFromRepo(ctx, c.Owner, c.Project) 466 | } 467 | 468 | // IssuesListByRepo calls the Issues.ListByRepo method with 469 | // the relevant owner and repo arguments. 470 | func (c *Client) IssuesListByRepo(ctx context.Context, opts *github.IssueListByRepoOptions) ([]*github.Issue, *github.Response, error) { 471 | return c.Issues.ListByRepo(ctx, c.Owner, c.Project, opts) 472 | } 473 | 474 | // IssuesGet calls the Issues.Get method with 475 | // the relevant owner and repo arguments. 476 | func (c *Client) IssuesGet(ctx context.Context, number int) (*github.Issue, *github.Response, error) { 477 | return c.Issues.Get(ctx, c.Owner, c.Project, number) 478 | } 479 | 480 | // IssuesCreate calls the Issues.Create method with 481 | // the relevant owner and repo arguments. 482 | func (c *Client) IssuesCreate(ctx context.Context, issue *github.IssueRequest) (*github.Issue, *github.Response, error) { 483 | return c.Issues.Create(ctx, c.Owner, c.Project, issue) 484 | } 485 | 486 | // IssuesEdit calls the Issues.Edit method with 487 | // the relevant owner and repo arguments. 488 | func (c *Client) IssuesEdit(ctx context.Context, number int, issue *github.IssueRequest) (*github.Issue, *github.Response, error) { 489 | return c.Issues.Edit(ctx, c.Owner, c.Project, number, issue) 490 | } 491 | 492 | // IssuesLock calls the Issues.Lock method with 493 | // the relevant owner and repo arguments. 494 | func (c *Client) IssuesLock(ctx context.Context, number int, opts *github.LockIssueOptions) (*github.Response, error) { 495 | return c.Issues.Lock(ctx, c.Owner, c.Project, number, opts) 496 | } 497 | 498 | // IssuesUnlock calls the Issues.Unlock method with 499 | // the relevant owner and repo arguments. 500 | func (c *Client) IssuesUnlock(ctx context.Context, number int) (*github.Response, error) { 501 | return c.Issues.Unlock(ctx, c.Owner, c.Project, number) 502 | } 503 | 504 | // IssuesListAssignees calls the Issues.ListAssignees method with 505 | // the relevant owner and repo arguments. 506 | func (c *Client) IssuesListAssignees(ctx context.Context, opts *github.ListOptions) ([]*github.User, *github.Response, error) { 507 | return c.Issues.ListAssignees(ctx, c.Owner, c.Project, opts) 508 | } 509 | 510 | // IssuesIsAssignee calls the Issues.IsAssignee method with 511 | // the relevant owner and repo arguments. 512 | func (c *Client) IssuesIsAssignee(ctx context.Context, user string) (bool, *github.Response, error) { 513 | return c.Issues.IsAssignee(ctx, c.Owner, c.Project, user) 514 | } 515 | 516 | // IssuesAddAssignees calls the Issues.AddAssignees method with 517 | // the relevant owner and repo arguments. 518 | func (c *Client) IssuesAddAssignees(ctx context.Context, number int, assignees []string) (*github.Issue, *github.Response, error) { 519 | return c.Issues.AddAssignees(ctx, c.Owner, c.Project, number, assignees) 520 | } 521 | 522 | // IssuesRemoveAssignees calls the Issues.RemoveAssignees method with 523 | // the relevant owner and repo arguments. 524 | func (c *Client) IssuesRemoveAssignees(ctx context.Context, number int, assignees []string) (*github.Issue, *github.Response, error) { 525 | return c.Issues.RemoveAssignees(ctx, c.Owner, c.Project, number, assignees) 526 | } 527 | 528 | // IssuesListComments calls the Issues.ListComments method with 529 | // the relevant owner and repo arguments. 530 | func (c *Client) IssuesListComments(ctx context.Context, number int, opts *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error) { 531 | return c.Issues.ListComments(ctx, c.Owner, c.Project, number, opts) 532 | } 533 | 534 | // IssuesGetComment calls the Issues.GetComment method with 535 | // the relevant owner and repo arguments. 536 | func (c *Client) IssuesGetComment(ctx context.Context, commentID int64) (*github.IssueComment, *github.Response, error) { 537 | return c.Issues.GetComment(ctx, c.Owner, c.Project, commentID) 538 | } 539 | 540 | // IssuesCreateComment calls the Issues.CreateComment method with 541 | // the relevant owner and repo arguments. 542 | func (c *Client) IssuesCreateComment(ctx context.Context, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error) { 543 | return c.Issues.CreateComment(ctx, c.Owner, c.Project, number, comment) 544 | } 545 | 546 | // IssuesEditComment calls the Issues.EditComment method with 547 | // the relevant owner and repo arguments. 548 | func (c *Client) IssuesEditComment(ctx context.Context, commentID int64, comment *github.IssueComment) (*github.IssueComment, *github.Response, error) { 549 | return c.Issues.EditComment(ctx, c.Owner, c.Project, commentID, comment) 550 | } 551 | 552 | // IssuesDeleteComment calls the Issues.DeleteComment method with 553 | // the relevant owner and repo arguments. 554 | func (c *Client) IssuesDeleteComment(ctx context.Context, commentID int64) (*github.Response, error) { 555 | return c.Issues.DeleteComment(ctx, c.Owner, c.Project, commentID) 556 | } 557 | 558 | // IssuesListIssueEvents calls the Issues.ListIssueEvents method with 559 | // the relevant owner and repo arguments. 560 | func (c *Client) IssuesListIssueEvents(ctx context.Context, number int, opts *github.ListOptions) ([]*github.IssueEvent, *github.Response, error) { 561 | return c.Issues.ListIssueEvents(ctx, c.Owner, c.Project, number, opts) 562 | } 563 | 564 | // IssuesListRepositoryEvents calls the Issues.ListRepositoryEvents method with 565 | // the relevant owner and repo arguments. 566 | func (c *Client) IssuesListRepositoryEvents(ctx context.Context, opts *github.ListOptions) ([]*github.IssueEvent, *github.Response, error) { 567 | return c.Issues.ListRepositoryEvents(ctx, c.Owner, c.Project, opts) 568 | } 569 | 570 | // IssuesGetEvent calls the Issues.GetEvent method with 571 | // the relevant owner and repo arguments. 572 | func (c *Client) IssuesGetEvent(ctx context.Context, id int64) (*github.IssueEvent, *github.Response, error) { 573 | return c.Issues.GetEvent(ctx, c.Owner, c.Project, id) 574 | } 575 | 576 | // IssuesListLabels calls the Issues.ListLabels method with 577 | // the relevant owner and repo arguments. 578 | func (c *Client) IssuesListLabels(ctx context.Context, opts *github.ListOptions) ([]*github.Label, *github.Response, error) { 579 | return c.Issues.ListLabels(ctx, c.Owner, c.Project, opts) 580 | } 581 | 582 | // IssuesGetLabel calls the Issues.GetLabel method with 583 | // the relevant owner and repo arguments. 584 | func (c *Client) IssuesGetLabel(ctx context.Context, name string) (*github.Label, *github.Response, error) { 585 | return c.Issues.GetLabel(ctx, c.Owner, c.Project, name) 586 | } 587 | 588 | // IssuesCreateLabel calls the Issues.CreateLabel method with 589 | // the relevant owner and repo arguments. 590 | func (c *Client) IssuesCreateLabel(ctx context.Context, label *github.Label) (*github.Label, *github.Response, error) { 591 | return c.Issues.CreateLabel(ctx, c.Owner, c.Project, label) 592 | } 593 | 594 | // IssuesEditLabel calls the Issues.EditLabel method with 595 | // the relevant owner and repo arguments. 596 | func (c *Client) IssuesEditLabel(ctx context.Context, name string, label *github.Label) (*github.Label, *github.Response, error) { 597 | return c.Issues.EditLabel(ctx, c.Owner, c.Project, name, label) 598 | } 599 | 600 | // IssuesDeleteLabel calls the Issues.DeleteLabel method with 601 | // the relevant owner and repo arguments. 602 | func (c *Client) IssuesDeleteLabel(ctx context.Context, name string) (*github.Response, error) { 603 | return c.Issues.DeleteLabel(ctx, c.Owner, c.Project, name) 604 | } 605 | 606 | // IssuesListLabelsByIssue calls the Issues.ListLabelsByIssue method with 607 | // the relevant owner and repo arguments. 608 | func (c *Client) IssuesListLabelsByIssue(ctx context.Context, number int, opts *github.ListOptions) ([]*github.Label, *github.Response, error) { 609 | return c.Issues.ListLabelsByIssue(ctx, c.Owner, c.Project, number, opts) 610 | } 611 | 612 | // IssuesAddLabelsToIssue calls the Issues.AddLabelsToIssue method with 613 | // the relevant owner and repo arguments. 614 | func (c *Client) IssuesAddLabelsToIssue(ctx context.Context, number int, labels []string) ([]*github.Label, *github.Response, error) { 615 | return c.Issues.AddLabelsToIssue(ctx, c.Owner, c.Project, number, labels) 616 | } 617 | 618 | // IssuesRemoveLabelForIssue calls the Issues.RemoveLabelForIssue method with 619 | // the relevant owner and repo arguments. 620 | func (c *Client) IssuesRemoveLabelForIssue(ctx context.Context, number int, label string) (*github.Response, error) { 621 | return c.Issues.RemoveLabelForIssue(ctx, c.Owner, c.Project, number, label) 622 | } 623 | 624 | // IssuesReplaceLabelsForIssue calls the Issues.ReplaceLabelsForIssue method with 625 | // the relevant owner and repo arguments. 626 | func (c *Client) IssuesReplaceLabelsForIssue(ctx context.Context, number int, labels []string) ([]*github.Label, *github.Response, error) { 627 | return c.Issues.ReplaceLabelsForIssue(ctx, c.Owner, c.Project, number, labels) 628 | } 629 | 630 | // IssuesRemoveLabelsForIssue calls the Issues.RemoveLabelsForIssue method with 631 | // the relevant owner and repo arguments. 632 | func (c *Client) IssuesRemoveLabelsForIssue(ctx context.Context, number int) (*github.Response, error) { 633 | return c.Issues.RemoveLabelsForIssue(ctx, c.Owner, c.Project, number) 634 | } 635 | 636 | // IssuesListLabelsForMilestone calls the Issues.ListLabelsForMilestone method with 637 | // the relevant owner and repo arguments. 638 | func (c *Client) IssuesListLabelsForMilestone(ctx context.Context, number int, opts *github.ListOptions) ([]*github.Label, *github.Response, error) { 639 | return c.Issues.ListLabelsForMilestone(ctx, c.Owner, c.Project, number, opts) 640 | } 641 | 642 | // IssuesListMilestones calls the Issues.ListMilestones method with 643 | // the relevant owner and repo arguments. 644 | func (c *Client) IssuesListMilestones(ctx context.Context, opts *github.MilestoneListOptions) ([]*github.Milestone, *github.Response, error) { 645 | return c.Issues.ListMilestones(ctx, c.Owner, c.Project, opts) 646 | } 647 | 648 | // IssuesGetMilestone calls the Issues.GetMilestone method with 649 | // the relevant owner and repo arguments. 650 | func (c *Client) IssuesGetMilestone(ctx context.Context, number int) (*github.Milestone, *github.Response, error) { 651 | return c.Issues.GetMilestone(ctx, c.Owner, c.Project, number) 652 | } 653 | 654 | // IssuesCreateMilestone calls the Issues.CreateMilestone method with 655 | // the relevant owner and repo arguments. 656 | func (c *Client) IssuesCreateMilestone(ctx context.Context, milestone *github.Milestone) (*github.Milestone, *github.Response, error) { 657 | return c.Issues.CreateMilestone(ctx, c.Owner, c.Project, milestone) 658 | } 659 | 660 | // IssuesEditMilestone calls the Issues.EditMilestone method with 661 | // the relevant owner and repo arguments. 662 | func (c *Client) IssuesEditMilestone(ctx context.Context, number int, milestone *github.Milestone) (*github.Milestone, *github.Response, error) { 663 | return c.Issues.EditMilestone(ctx, c.Owner, c.Project, number, milestone) 664 | } 665 | 666 | // IssuesDeleteMilestone calls the Issues.DeleteMilestone method with 667 | // the relevant owner and repo arguments. 668 | func (c *Client) IssuesDeleteMilestone(ctx context.Context, number int) (*github.Response, error) { 669 | return c.Issues.DeleteMilestone(ctx, c.Owner, c.Project, number) 670 | } 671 | 672 | // IssuesListIssueTimeline calls the Issues.ListIssueTimeline method with 673 | // the relevant owner and repo arguments. 674 | func (c *Client) IssuesListIssueTimeline(ctx context.Context, number int, opts *github.ListOptions) ([]*github.Timeline, *github.Response, error) { 675 | return c.Issues.ListIssueTimeline(ctx, c.Owner, c.Project, number, opts) 676 | } 677 | 678 | // MigrationsStartImport calls the Migrations.StartImport method with 679 | // the relevant owner and repo arguments. 680 | func (c *Client) MigrationsStartImport(ctx context.Context, in *github.Import) (*github.Import, *github.Response, error) { 681 | return c.Migrations.StartImport(ctx, c.Owner, c.Project, in) 682 | } 683 | 684 | // MigrationsImportProgress calls the Migrations.ImportProgress method with 685 | // the relevant owner and repo arguments. 686 | func (c *Client) MigrationsImportProgress(ctx context.Context) (*github.Import, *github.Response, error) { 687 | return c.Migrations.ImportProgress(ctx, c.Owner, c.Project) 688 | } 689 | 690 | // MigrationsUpdateImport calls the Migrations.UpdateImport method with 691 | // the relevant owner and repo arguments. 692 | func (c *Client) MigrationsUpdateImport(ctx context.Context, in *github.Import) (*github.Import, *github.Response, error) { 693 | return c.Migrations.UpdateImport(ctx, c.Owner, c.Project, in) 694 | } 695 | 696 | // MigrationsCommitAuthors calls the Migrations.CommitAuthors method with 697 | // the relevant owner and repo arguments. 698 | func (c *Client) MigrationsCommitAuthors(ctx context.Context) ([]*github.SourceImportAuthor, *github.Response, error) { 699 | return c.Migrations.CommitAuthors(ctx, c.Owner, c.Project) 700 | } 701 | 702 | // MigrationsMapCommitAuthor calls the Migrations.MapCommitAuthor method with 703 | // the relevant owner and repo arguments. 704 | func (c *Client) MigrationsMapCommitAuthor(ctx context.Context, id int64, author *github.SourceImportAuthor) (*github.SourceImportAuthor, *github.Response, error) { 705 | return c.Migrations.MapCommitAuthor(ctx, c.Owner, c.Project, id, author) 706 | } 707 | 708 | // MigrationsSetLFSPreference calls the Migrations.SetLFSPreference method with 709 | // the relevant owner and repo arguments. 710 | func (c *Client) MigrationsSetLFSPreference(ctx context.Context, in *github.Import) (*github.Import, *github.Response, error) { 711 | return c.Migrations.SetLFSPreference(ctx, c.Owner, c.Project, in) 712 | } 713 | 714 | // MigrationsLargeFiles calls the Migrations.LargeFiles method with 715 | // the relevant owner and repo arguments. 716 | func (c *Client) MigrationsLargeFiles(ctx context.Context) ([]*github.LargeFile, *github.Response, error) { 717 | return c.Migrations.LargeFiles(ctx, c.Owner, c.Project) 718 | } 719 | 720 | // MigrationsCancelImport calls the Migrations.CancelImport method with 721 | // the relevant owner and repo arguments. 722 | func (c *Client) MigrationsCancelImport(ctx context.Context) (*github.Response, error) { 723 | return c.Migrations.CancelImport(ctx, c.Owner, c.Project) 724 | } 725 | 726 | // PullRequestsList calls the PullRequests.List method with 727 | // the relevant owner and repo arguments. 728 | func (c *Client) PullRequestsList(ctx context.Context, opts *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) { 729 | return c.PullRequests.List(ctx, c.Owner, c.Project, opts) 730 | } 731 | 732 | // PullRequestsListPullRequestsWithCommit calls the PullRequests.ListPullRequestsWithCommit method with 733 | // the relevant owner and repo arguments. 734 | func (c *Client) PullRequestsListPullRequestsWithCommit(ctx context.Context, sha string, opts *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) { 735 | return c.PullRequests.ListPullRequestsWithCommit(ctx, c.Owner, c.Project, sha, opts) 736 | } 737 | 738 | // PullRequestsGet calls the PullRequests.Get method with 739 | // the relevant owner and repo arguments. 740 | func (c *Client) PullRequestsGet(ctx context.Context, number int) (*github.PullRequest, *github.Response, error) { 741 | return c.PullRequests.Get(ctx, c.Owner, c.Project, number) 742 | } 743 | 744 | // PullRequestsGetRaw calls the PullRequests.GetRaw method with 745 | // the relevant owner and repo arguments. 746 | func (c *Client) PullRequestsGetRaw(ctx context.Context, number int, opts github.RawOptions) (string, *github.Response, error) { 747 | return c.PullRequests.GetRaw(ctx, c.Owner, c.Project, number, opts) 748 | } 749 | 750 | // PullRequestsCreate calls the PullRequests.Create method with 751 | // the relevant owner and repo arguments. 752 | func (c *Client) PullRequestsCreate(ctx context.Context, pull *github.NewPullRequest) (*github.PullRequest, *github.Response, error) { 753 | return c.PullRequests.Create(ctx, c.Owner, c.Project, pull) 754 | } 755 | 756 | // PullRequestsUpdateBranch calls the PullRequests.UpdateBranch method with 757 | // the relevant owner and repo arguments. 758 | func (c *Client) PullRequestsUpdateBranch(ctx context.Context, number int, opts *github.PullRequestBranchUpdateOptions) (*github.PullRequestBranchUpdateResponse, *github.Response, error) { 759 | return c.PullRequests.UpdateBranch(ctx, c.Owner, c.Project, number, opts) 760 | } 761 | 762 | // PullRequestsEdit calls the PullRequests.Edit method with 763 | // the relevant owner and repo arguments. 764 | func (c *Client) PullRequestsEdit(ctx context.Context, number int, pull *github.PullRequest) (*github.PullRequest, *github.Response, error) { 765 | return c.PullRequests.Edit(ctx, c.Owner, c.Project, number, pull) 766 | } 767 | 768 | // PullRequestsListCommits calls the PullRequests.ListCommits method with 769 | // the relevant owner and repo arguments. 770 | func (c *Client) PullRequestsListCommits(ctx context.Context, number int, opts *github.ListOptions) ([]*github.RepositoryCommit, *github.Response, error) { 771 | return c.PullRequests.ListCommits(ctx, c.Owner, c.Project, number, opts) 772 | } 773 | 774 | // PullRequestsListFiles calls the PullRequests.ListFiles method with 775 | // the relevant owner and repo arguments. 776 | func (c *Client) PullRequestsListFiles(ctx context.Context, number int, opts *github.ListOptions) ([]*github.CommitFile, *github.Response, error) { 777 | return c.PullRequests.ListFiles(ctx, c.Owner, c.Project, number, opts) 778 | } 779 | 780 | // PullRequestsIsMerged calls the PullRequests.IsMerged method with 781 | // the relevant owner and repo arguments. 782 | func (c *Client) PullRequestsIsMerged(ctx context.Context, number int) (bool, *github.Response, error) { 783 | return c.PullRequests.IsMerged(ctx, c.Owner, c.Project, number) 784 | } 785 | 786 | // PullRequestsMerge calls the PullRequests.Merge method with 787 | // the relevant owner and repo arguments. 788 | func (c *Client) PullRequestsMerge(ctx context.Context, number int, commitMessage string, options *github.PullRequestOptions) (*github.PullRequestMergeResult, *github.Response, error) { 789 | return c.PullRequests.Merge(ctx, c.Owner, c.Project, number, commitMessage, options) 790 | } 791 | 792 | // PullRequestsListComments calls the PullRequests.ListComments method with 793 | // the relevant owner and repo arguments. 794 | func (c *Client) PullRequestsListComments(ctx context.Context, number int, opts *github.PullRequestListCommentsOptions) ([]*github.PullRequestComment, *github.Response, error) { 795 | return c.PullRequests.ListComments(ctx, c.Owner, c.Project, number, opts) 796 | } 797 | 798 | // PullRequestsGetComment calls the PullRequests.GetComment method with 799 | // the relevant owner and repo arguments. 800 | func (c *Client) PullRequestsGetComment(ctx context.Context, commentID int64) (*github.PullRequestComment, *github.Response, error) { 801 | return c.PullRequests.GetComment(ctx, c.Owner, c.Project, commentID) 802 | } 803 | 804 | // PullRequestsCreateComment calls the PullRequests.CreateComment method with 805 | // the relevant owner and repo arguments. 806 | func (c *Client) PullRequestsCreateComment(ctx context.Context, number int, comment *github.PullRequestComment) (*github.PullRequestComment, *github.Response, error) { 807 | return c.PullRequests.CreateComment(ctx, c.Owner, c.Project, number, comment) 808 | } 809 | 810 | // PullRequestsCreateCommentInReplyTo calls the PullRequests.CreateCommentInReplyTo method with 811 | // the relevant owner and repo arguments. 812 | func (c *Client) PullRequestsCreateCommentInReplyTo(ctx context.Context, number int, body string, commentID int64) (*github.PullRequestComment, *github.Response, error) { 813 | return c.PullRequests.CreateCommentInReplyTo(ctx, c.Owner, c.Project, number, body, commentID) 814 | } 815 | 816 | // PullRequestsEditComment calls the PullRequests.EditComment method with 817 | // the relevant owner and repo arguments. 818 | func (c *Client) PullRequestsEditComment(ctx context.Context, commentID int64, comment *github.PullRequestComment) (*github.PullRequestComment, *github.Response, error) { 819 | return c.PullRequests.EditComment(ctx, c.Owner, c.Project, commentID, comment) 820 | } 821 | 822 | // PullRequestsDeleteComment calls the PullRequests.DeleteComment method with 823 | // the relevant owner and repo arguments. 824 | func (c *Client) PullRequestsDeleteComment(ctx context.Context, commentID int64) (*github.Response, error) { 825 | return c.PullRequests.DeleteComment(ctx, c.Owner, c.Project, commentID) 826 | } 827 | 828 | // PullRequestsRequestReviewers calls the PullRequests.RequestReviewers method with 829 | // the relevant owner and repo arguments. 830 | func (c *Client) PullRequestsRequestReviewers(ctx context.Context, number int, reviewers github.ReviewersRequest) (*github.PullRequest, *github.Response, error) { 831 | return c.PullRequests.RequestReviewers(ctx, c.Owner, c.Project, number, reviewers) 832 | } 833 | 834 | // PullRequestsListReviewers calls the PullRequests.ListReviewers method with 835 | // the relevant owner and repo arguments. 836 | func (c *Client) PullRequestsListReviewers(ctx context.Context, number int, opts *github.ListOptions) (*github.Reviewers, *github.Response, error) { 837 | return c.PullRequests.ListReviewers(ctx, c.Owner, c.Project, number, opts) 838 | } 839 | 840 | // PullRequestsRemoveReviewers calls the PullRequests.RemoveReviewers method with 841 | // the relevant owner and repo arguments. 842 | func (c *Client) PullRequestsRemoveReviewers(ctx context.Context, number int, reviewers github.ReviewersRequest) (*github.Response, error) { 843 | return c.PullRequests.RemoveReviewers(ctx, c.Owner, c.Project, number, reviewers) 844 | } 845 | 846 | // PullRequestsListReviews calls the PullRequests.ListReviews method with 847 | // the relevant owner and repo arguments. 848 | func (c *Client) PullRequestsListReviews(ctx context.Context, number int, opts *github.ListOptions) ([]*github.PullRequestReview, *github.Response, error) { 849 | return c.PullRequests.ListReviews(ctx, c.Owner, c.Project, number, opts) 850 | } 851 | 852 | // PullRequestsGetReview calls the PullRequests.GetReview method with 853 | // the relevant owner and repo arguments. 854 | func (c *Client) PullRequestsGetReview(ctx context.Context, number int, reviewID int64) (*github.PullRequestReview, *github.Response, error) { 855 | return c.PullRequests.GetReview(ctx, c.Owner, c.Project, number, reviewID) 856 | } 857 | 858 | // PullRequestsDeletePendingReview calls the PullRequests.DeletePendingReview method with 859 | // the relevant owner and repo arguments. 860 | func (c *Client) PullRequestsDeletePendingReview(ctx context.Context, number int, reviewID int64) (*github.PullRequestReview, *github.Response, error) { 861 | return c.PullRequests.DeletePendingReview(ctx, c.Owner, c.Project, number, reviewID) 862 | } 863 | 864 | // PullRequestsListReviewComments calls the PullRequests.ListReviewComments method with 865 | // the relevant owner and repo arguments. 866 | func (c *Client) PullRequestsListReviewComments(ctx context.Context, number int, reviewID int64, opts *github.ListOptions) ([]*github.PullRequestComment, *github.Response, error) { 867 | return c.PullRequests.ListReviewComments(ctx, c.Owner, c.Project, number, reviewID, opts) 868 | } 869 | 870 | // PullRequestsCreateReview calls the PullRequests.CreateReview method with 871 | // the relevant owner and repo arguments. 872 | func (c *Client) PullRequestsCreateReview(ctx context.Context, number int, review *github.PullRequestReviewRequest) (*github.PullRequestReview, *github.Response, error) { 873 | return c.PullRequests.CreateReview(ctx, c.Owner, c.Project, number, review) 874 | } 875 | 876 | // PullRequestsUpdateReview calls the PullRequests.UpdateReview method with 877 | // the relevant owner and repo arguments. 878 | func (c *Client) PullRequestsUpdateReview(ctx context.Context, number int, reviewID int64, body string) (*github.PullRequestReview, *github.Response, error) { 879 | return c.PullRequests.UpdateReview(ctx, c.Owner, c.Project, number, reviewID, body) 880 | } 881 | 882 | // PullRequestsSubmitReview calls the PullRequests.SubmitReview method with 883 | // the relevant owner and repo arguments. 884 | func (c *Client) PullRequestsSubmitReview(ctx context.Context, number int, reviewID int64, review *github.PullRequestReviewRequest) (*github.PullRequestReview, *github.Response, error) { 885 | return c.PullRequests.SubmitReview(ctx, c.Owner, c.Project, number, reviewID, review) 886 | } 887 | 888 | // PullRequestsDismissReview calls the PullRequests.DismissReview method with 889 | // the relevant owner and repo arguments. 890 | func (c *Client) PullRequestsDismissReview(ctx context.Context, number int, reviewID int64, review *github.PullRequestReviewDismissalRequest) (*github.PullRequestReview, *github.Response, error) { 891 | return c.PullRequests.DismissReview(ctx, c.Owner, c.Project, number, reviewID, review) 892 | } 893 | 894 | // ReactionsListCommentReactions calls the Reactions.ListCommentReactions method with 895 | // the relevant owner and repo arguments. 896 | func (c *Client) ReactionsListCommentReactions(ctx context.Context, id int64, opts *github.ListCommentReactionOptions) ([]*github.Reaction, *github.Response, error) { 897 | return c.Reactions.ListCommentReactions(ctx, c.Owner, c.Project, id, opts) 898 | } 899 | 900 | // ReactionsCreateCommentReaction calls the Reactions.CreateCommentReaction method with 901 | // the relevant owner and repo arguments. 902 | func (c *Client) ReactionsCreateCommentReaction(ctx context.Context, id int64, content string) (*github.Reaction, *github.Response, error) { 903 | return c.Reactions.CreateCommentReaction(ctx, c.Owner, c.Project, id, content) 904 | } 905 | 906 | // ReactionsDeleteCommentReaction calls the Reactions.DeleteCommentReaction method with 907 | // the relevant owner and repo arguments. 908 | func (c *Client) ReactionsDeleteCommentReaction(ctx context.Context, commentID int64, reactionID int64) (*github.Response, error) { 909 | return c.Reactions.DeleteCommentReaction(ctx, c.Owner, c.Project, commentID, reactionID) 910 | } 911 | 912 | // ReactionsListIssueReactions calls the Reactions.ListIssueReactions method with 913 | // the relevant owner and repo arguments. 914 | func (c *Client) ReactionsListIssueReactions(ctx context.Context, number int, opts *github.ListOptions) ([]*github.Reaction, *github.Response, error) { 915 | return c.Reactions.ListIssueReactions(ctx, c.Owner, c.Project, number, opts) 916 | } 917 | 918 | // ReactionsCreateIssueReaction calls the Reactions.CreateIssueReaction method with 919 | // the relevant owner and repo arguments. 920 | func (c *Client) ReactionsCreateIssueReaction(ctx context.Context, number int, content string) (*github.Reaction, *github.Response, error) { 921 | return c.Reactions.CreateIssueReaction(ctx, c.Owner, c.Project, number, content) 922 | } 923 | 924 | // ReactionsDeleteIssueReaction calls the Reactions.DeleteIssueReaction method with 925 | // the relevant owner and repo arguments. 926 | func (c *Client) ReactionsDeleteIssueReaction(ctx context.Context, issueNumber int, reactionID int64) (*github.Response, error) { 927 | return c.Reactions.DeleteIssueReaction(ctx, c.Owner, c.Project, issueNumber, reactionID) 928 | } 929 | 930 | // ReactionsListIssueCommentReactions calls the Reactions.ListIssueCommentReactions method with 931 | // the relevant owner and repo arguments. 932 | func (c *Client) ReactionsListIssueCommentReactions(ctx context.Context, id int64, opts *github.ListOptions) ([]*github.Reaction, *github.Response, error) { 933 | return c.Reactions.ListIssueCommentReactions(ctx, c.Owner, c.Project, id, opts) 934 | } 935 | 936 | // ReactionsCreateIssueCommentReaction calls the Reactions.CreateIssueCommentReaction method with 937 | // the relevant owner and repo arguments. 938 | func (c *Client) ReactionsCreateIssueCommentReaction(ctx context.Context, id int64, content string) (*github.Reaction, *github.Response, error) { 939 | return c.Reactions.CreateIssueCommentReaction(ctx, c.Owner, c.Project, id, content) 940 | } 941 | 942 | // ReactionsDeleteIssueCommentReaction calls the Reactions.DeleteIssueCommentReaction method with 943 | // the relevant owner and repo arguments. 944 | func (c *Client) ReactionsDeleteIssueCommentReaction(ctx context.Context, commentID int64, reactionID int64) (*github.Response, error) { 945 | return c.Reactions.DeleteIssueCommentReaction(ctx, c.Owner, c.Project, commentID, reactionID) 946 | } 947 | 948 | // ReactionsListPullRequestCommentReactions calls the Reactions.ListPullRequestCommentReactions method with 949 | // the relevant owner and repo arguments. 950 | func (c *Client) ReactionsListPullRequestCommentReactions(ctx context.Context, id int64, opts *github.ListOptions) ([]*github.Reaction, *github.Response, error) { 951 | return c.Reactions.ListPullRequestCommentReactions(ctx, c.Owner, c.Project, id, opts) 952 | } 953 | 954 | // ReactionsCreatePullRequestCommentReaction calls the Reactions.CreatePullRequestCommentReaction method with 955 | // the relevant owner and repo arguments. 956 | func (c *Client) ReactionsCreatePullRequestCommentReaction(ctx context.Context, id int64, content string) (*github.Reaction, *github.Response, error) { 957 | return c.Reactions.CreatePullRequestCommentReaction(ctx, c.Owner, c.Project, id, content) 958 | } 959 | 960 | // ReactionsDeletePullRequestCommentReaction calls the Reactions.DeletePullRequestCommentReaction method with 961 | // the relevant owner and repo arguments. 962 | func (c *Client) ReactionsDeletePullRequestCommentReaction(ctx context.Context, commentID int64, reactionID int64) (*github.Response, error) { 963 | return c.Reactions.DeletePullRequestCommentReaction(ctx, c.Owner, c.Project, commentID, reactionID) 964 | } 965 | 966 | // RepositoriesGet calls the Repositories.Get method with 967 | // the relevant owner and repo arguments. 968 | func (c *Client) RepositoriesGet(ctx context.Context) (*github.Repository, *github.Response, error) { 969 | return c.Repositories.Get(ctx, c.Owner, c.Project) 970 | } 971 | 972 | // RepositoriesGetCodeOfConduct calls the Repositories.GetCodeOfConduct method with 973 | // the relevant owner and repo arguments. 974 | func (c *Client) RepositoriesGetCodeOfConduct(ctx context.Context) (*github.CodeOfConduct, *github.Response, error) { 975 | return c.Repositories.GetCodeOfConduct(ctx, c.Owner, c.Project) 976 | } 977 | 978 | // RepositoriesEdit calls the Repositories.Edit method with 979 | // the relevant owner and repo arguments. 980 | func (c *Client) RepositoriesEdit(ctx context.Context, repository *github.Repository) (*github.Repository, *github.Response, error) { 981 | return c.Repositories.Edit(ctx, c.Owner, c.Project, repository) 982 | } 983 | 984 | // RepositoriesDelete calls the Repositories.Delete method with 985 | // the relevant owner and repo arguments. 986 | func (c *Client) RepositoriesDelete(ctx context.Context) (*github.Response, error) { 987 | return c.Repositories.Delete(ctx, c.Owner, c.Project) 988 | } 989 | 990 | // RepositoriesListLanguages calls the Repositories.ListLanguages method with 991 | // the relevant owner and repo arguments. 992 | func (c *Client) RepositoriesListLanguages(ctx context.Context) (map[string]int, *github.Response, error) { 993 | return c.Repositories.ListLanguages(ctx, c.Owner, c.Project) 994 | } 995 | 996 | // RepositoriesListTeams calls the Repositories.ListTeams method with 997 | // the relevant owner and repo arguments. 998 | func (c *Client) RepositoriesListTeams(ctx context.Context, opts *github.ListOptions) ([]*github.Team, *github.Response, error) { 999 | return c.Repositories.ListTeams(ctx, c.Owner, c.Project, opts) 1000 | } 1001 | 1002 | // RepositoriesListTags calls the Repositories.ListTags method with 1003 | // the relevant owner and repo arguments. 1004 | func (c *Client) RepositoriesListTags(ctx context.Context, opts *github.ListOptions) ([]*github.RepositoryTag, *github.Response, error) { 1005 | return c.Repositories.ListTags(ctx, c.Owner, c.Project, opts) 1006 | } 1007 | 1008 | // RepositoriesListBranches calls the Repositories.ListBranches method with 1009 | // the relevant owner and repo arguments. 1010 | func (c *Client) RepositoriesListBranches(ctx context.Context, opts *github.BranchListOptions) ([]*github.Branch, *github.Response, error) { 1011 | return c.Repositories.ListBranches(ctx, c.Owner, c.Project, opts) 1012 | } 1013 | 1014 | // RepositoriesGetBranch calls the Repositories.GetBranch method with 1015 | // the relevant owner and repo arguments. 1016 | func (c *Client) RepositoriesGetBranch(ctx context.Context, branch string) (*github.Branch, *github.Response, error) { 1017 | return c.Repositories.GetBranch(ctx, c.Owner, c.Project, branch) 1018 | } 1019 | 1020 | // RepositoriesGetBranchProtection calls the Repositories.GetBranchProtection method with 1021 | // the relevant owner and repo arguments. 1022 | func (c *Client) RepositoriesGetBranchProtection(ctx context.Context, branch string) (*github.Protection, *github.Response, error) { 1023 | return c.Repositories.GetBranchProtection(ctx, c.Owner, c.Project, branch) 1024 | } 1025 | 1026 | // RepositoriesGetRequiredStatusChecks calls the Repositories.GetRequiredStatusChecks method with 1027 | // the relevant owner and repo arguments. 1028 | func (c *Client) RepositoriesGetRequiredStatusChecks(ctx context.Context, branch string) (*github.RequiredStatusChecks, *github.Response, error) { 1029 | return c.Repositories.GetRequiredStatusChecks(ctx, c.Owner, c.Project, branch) 1030 | } 1031 | 1032 | // RepositoriesListRequiredStatusChecksContexts calls the Repositories.ListRequiredStatusChecksContexts method with 1033 | // the relevant owner and repo arguments. 1034 | func (c *Client) RepositoriesListRequiredStatusChecksContexts(ctx context.Context, branch string) (contexts []string, resp *github.Response, err error) { 1035 | return c.Repositories.ListRequiredStatusChecksContexts(ctx, c.Owner, c.Project, branch) 1036 | } 1037 | 1038 | // RepositoriesUpdateBranchProtection calls the Repositories.UpdateBranchProtection method with 1039 | // the relevant owner and repo arguments. 1040 | func (c *Client) RepositoriesUpdateBranchProtection(ctx context.Context, branch string, preq *github.ProtectionRequest) (*github.Protection, *github.Response, error) { 1041 | return c.Repositories.UpdateBranchProtection(ctx, c.Owner, c.Project, branch, preq) 1042 | } 1043 | 1044 | // RepositoriesRemoveBranchProtection calls the Repositories.RemoveBranchProtection method with 1045 | // the relevant owner and repo arguments. 1046 | func (c *Client) RepositoriesRemoveBranchProtection(ctx context.Context, branch string) (*github.Response, error) { 1047 | return c.Repositories.RemoveBranchProtection(ctx, c.Owner, c.Project, branch) 1048 | } 1049 | 1050 | // RepositoriesGetSignaturesProtectedBranch calls the Repositories.GetSignaturesProtectedBranch method with 1051 | // the relevant owner and repo arguments. 1052 | func (c *Client) RepositoriesGetSignaturesProtectedBranch(ctx context.Context, branch string) (*github.SignaturesProtectedBranch, *github.Response, error) { 1053 | return c.Repositories.GetSignaturesProtectedBranch(ctx, c.Owner, c.Project, branch) 1054 | } 1055 | 1056 | // RepositoriesRequireSignaturesOnProtectedBranch calls the Repositories.RequireSignaturesOnProtectedBranch method with 1057 | // the relevant owner and repo arguments. 1058 | func (c *Client) RepositoriesRequireSignaturesOnProtectedBranch(ctx context.Context, branch string) (*github.SignaturesProtectedBranch, *github.Response, error) { 1059 | return c.Repositories.RequireSignaturesOnProtectedBranch(ctx, c.Owner, c.Project, branch) 1060 | } 1061 | 1062 | // RepositoriesOptionalSignaturesOnProtectedBranch calls the Repositories.OptionalSignaturesOnProtectedBranch method with 1063 | // the relevant owner and repo arguments. 1064 | func (c *Client) RepositoriesOptionalSignaturesOnProtectedBranch(ctx context.Context, branch string) (*github.Response, error) { 1065 | return c.Repositories.OptionalSignaturesOnProtectedBranch(ctx, c.Owner, c.Project, branch) 1066 | } 1067 | 1068 | // RepositoriesUpdateRequiredStatusChecks calls the Repositories.UpdateRequiredStatusChecks method with 1069 | // the relevant owner and repo arguments. 1070 | func (c *Client) RepositoriesUpdateRequiredStatusChecks(ctx context.Context, branch string, sreq *github.RequiredStatusChecksRequest) (*github.RequiredStatusChecks, *github.Response, error) { 1071 | return c.Repositories.UpdateRequiredStatusChecks(ctx, c.Owner, c.Project, branch, sreq) 1072 | } 1073 | 1074 | // RepositoriesLicense calls the Repositories.License method with 1075 | // the relevant owner and repo arguments. 1076 | func (c *Client) RepositoriesLicense(ctx context.Context) (*github.RepositoryLicense, *github.Response, error) { 1077 | return c.Repositories.License(ctx, c.Owner, c.Project) 1078 | } 1079 | 1080 | // RepositoriesGetPullRequestReviewEnforcement calls the Repositories.GetPullRequestReviewEnforcement method with 1081 | // the relevant owner and repo arguments. 1082 | func (c *Client) RepositoriesGetPullRequestReviewEnforcement(ctx context.Context, branch string) (*github.PullRequestReviewsEnforcement, *github.Response, error) { 1083 | return c.Repositories.GetPullRequestReviewEnforcement(ctx, c.Owner, c.Project, branch) 1084 | } 1085 | 1086 | // RepositoriesUpdatePullRequestReviewEnforcement calls the Repositories.UpdatePullRequestReviewEnforcement method with 1087 | // the relevant owner and repo arguments. 1088 | func (c *Client) RepositoriesUpdatePullRequestReviewEnforcement(ctx context.Context, branch string, patch *github.PullRequestReviewsEnforcementUpdate) (*github.PullRequestReviewsEnforcement, *github.Response, error) { 1089 | return c.Repositories.UpdatePullRequestReviewEnforcement(ctx, c.Owner, c.Project, branch, patch) 1090 | } 1091 | 1092 | // RepositoriesDisableDismissalRestrictions calls the Repositories.DisableDismissalRestrictions method with 1093 | // the relevant owner and repo arguments. 1094 | func (c *Client) RepositoriesDisableDismissalRestrictions(ctx context.Context, branch string) (*github.PullRequestReviewsEnforcement, *github.Response, error) { 1095 | return c.Repositories.DisableDismissalRestrictions(ctx, c.Owner, c.Project, branch) 1096 | } 1097 | 1098 | // RepositoriesRemovePullRequestReviewEnforcement calls the Repositories.RemovePullRequestReviewEnforcement method with 1099 | // the relevant owner and repo arguments. 1100 | func (c *Client) RepositoriesRemovePullRequestReviewEnforcement(ctx context.Context, branch string) (*github.Response, error) { 1101 | return c.Repositories.RemovePullRequestReviewEnforcement(ctx, c.Owner, c.Project, branch) 1102 | } 1103 | 1104 | // RepositoriesGetAdminEnforcement calls the Repositories.GetAdminEnforcement method with 1105 | // the relevant owner and repo arguments. 1106 | func (c *Client) RepositoriesGetAdminEnforcement(ctx context.Context, branch string) (*github.AdminEnforcement, *github.Response, error) { 1107 | return c.Repositories.GetAdminEnforcement(ctx, c.Owner, c.Project, branch) 1108 | } 1109 | 1110 | // RepositoriesAddAdminEnforcement calls the Repositories.AddAdminEnforcement method with 1111 | // the relevant owner and repo arguments. 1112 | func (c *Client) RepositoriesAddAdminEnforcement(ctx context.Context, branch string) (*github.AdminEnforcement, *github.Response, error) { 1113 | return c.Repositories.AddAdminEnforcement(ctx, c.Owner, c.Project, branch) 1114 | } 1115 | 1116 | // RepositoriesRemoveAdminEnforcement calls the Repositories.RemoveAdminEnforcement method with 1117 | // the relevant owner and repo arguments. 1118 | func (c *Client) RepositoriesRemoveAdminEnforcement(ctx context.Context, branch string) (*github.Response, error) { 1119 | return c.Repositories.RemoveAdminEnforcement(ctx, c.Owner, c.Project, branch) 1120 | } 1121 | 1122 | // RepositoriesListAllTopics calls the Repositories.ListAllTopics method with 1123 | // the relevant owner and repo arguments. 1124 | func (c *Client) RepositoriesListAllTopics(ctx context.Context) ([]string, *github.Response, error) { 1125 | return c.Repositories.ListAllTopics(ctx, c.Owner, c.Project) 1126 | } 1127 | 1128 | // RepositoriesReplaceAllTopics calls the Repositories.ReplaceAllTopics method with 1129 | // the relevant owner and repo arguments. 1130 | func (c *Client) RepositoriesReplaceAllTopics(ctx context.Context, topics []string) ([]string, *github.Response, error) { 1131 | return c.Repositories.ReplaceAllTopics(ctx, c.Owner, c.Project, topics) 1132 | } 1133 | 1134 | // RepositoriesListApps calls the Repositories.ListApps method with 1135 | // the relevant owner and repo arguments. 1136 | func (c *Client) RepositoriesListApps(ctx context.Context, branch string) ([]*github.App, *github.Response, error) { 1137 | return c.Repositories.ListApps(ctx, c.Owner, c.Project, branch) 1138 | } 1139 | 1140 | // RepositoriesReplaceAppRestrictions calls the Repositories.ReplaceAppRestrictions method with 1141 | // the relevant owner and repo arguments. 1142 | func (c *Client) RepositoriesReplaceAppRestrictions(ctx context.Context, branch string, slug []string) ([]*github.App, *github.Response, error) { 1143 | return c.Repositories.ReplaceAppRestrictions(ctx, c.Owner, c.Project, branch, slug) 1144 | } 1145 | 1146 | // RepositoriesAddAppRestrictions calls the Repositories.AddAppRestrictions method with 1147 | // the relevant owner and repo arguments. 1148 | func (c *Client) RepositoriesAddAppRestrictions(ctx context.Context, branch string, slug []string) ([]*github.App, *github.Response, error) { 1149 | return c.Repositories.AddAppRestrictions(ctx, c.Owner, c.Project, branch, slug) 1150 | } 1151 | 1152 | // RepositoriesRemoveAppRestrictions calls the Repositories.RemoveAppRestrictions method with 1153 | // the relevant owner and repo arguments. 1154 | func (c *Client) RepositoriesRemoveAppRestrictions(ctx context.Context, branch string, slug []string) ([]*github.App, *github.Response, error) { 1155 | return c.Repositories.RemoveAppRestrictions(ctx, c.Owner, c.Project, branch, slug) 1156 | } 1157 | 1158 | // RepositoriesTransfer calls the Repositories.Transfer method with 1159 | // the relevant owner and repo arguments. 1160 | func (c *Client) RepositoriesTransfer(ctx context.Context, transfer github.TransferRequest) (*github.Repository, *github.Response, error) { 1161 | return c.Repositories.Transfer(ctx, c.Owner, c.Project, transfer) 1162 | } 1163 | 1164 | // RepositoriesDispatch calls the Repositories.Dispatch method with 1165 | // the relevant owner and repo arguments. 1166 | func (c *Client) RepositoriesDispatch(ctx context.Context, opts github.DispatchRequestOptions) (*github.Repository, *github.Response, error) { 1167 | return c.Repositories.Dispatch(ctx, c.Owner, c.Project, opts) 1168 | } 1169 | 1170 | // RepositoriesListCollaborators calls the Repositories.ListCollaborators method with 1171 | // the relevant owner and repo arguments. 1172 | func (c *Client) RepositoriesListCollaborators(ctx context.Context, opts *github.ListCollaboratorsOptions) ([]*github.User, *github.Response, error) { 1173 | return c.Repositories.ListCollaborators(ctx, c.Owner, c.Project, opts) 1174 | } 1175 | 1176 | // RepositoriesIsCollaborator calls the Repositories.IsCollaborator method with 1177 | // the relevant owner and repo arguments. 1178 | func (c *Client) RepositoriesIsCollaborator(ctx context.Context, user string) (bool, *github.Response, error) { 1179 | return c.Repositories.IsCollaborator(ctx, c.Owner, c.Project, user) 1180 | } 1181 | 1182 | // RepositoriesGetPermissionLevel calls the Repositories.GetPermissionLevel method with 1183 | // the relevant owner and repo arguments. 1184 | func (c *Client) RepositoriesGetPermissionLevel(ctx context.Context, user string) (*github.RepositoryPermissionLevel, *github.Response, error) { 1185 | return c.Repositories.GetPermissionLevel(ctx, c.Owner, c.Project, user) 1186 | } 1187 | 1188 | // RepositoriesAddCollaborator calls the Repositories.AddCollaborator method with 1189 | // the relevant owner and repo arguments. 1190 | func (c *Client) RepositoriesAddCollaborator(ctx context.Context, user string, opts *github.RepositoryAddCollaboratorOptions) (*github.CollaboratorInvitation, *github.Response, error) { 1191 | return c.Repositories.AddCollaborator(ctx, c.Owner, c.Project, user, opts) 1192 | } 1193 | 1194 | // RepositoriesRemoveCollaborator calls the Repositories.RemoveCollaborator method with 1195 | // the relevant owner and repo arguments. 1196 | func (c *Client) RepositoriesRemoveCollaborator(ctx context.Context, user string) (*github.Response, error) { 1197 | return c.Repositories.RemoveCollaborator(ctx, c.Owner, c.Project, user) 1198 | } 1199 | 1200 | // RepositoriesListComments calls the Repositories.ListComments method with 1201 | // the relevant owner and repo arguments. 1202 | func (c *Client) RepositoriesListComments(ctx context.Context, opts *github.ListOptions) ([]*github.RepositoryComment, *github.Response, error) { 1203 | return c.Repositories.ListComments(ctx, c.Owner, c.Project, opts) 1204 | } 1205 | 1206 | // RepositoriesListCommitComments calls the Repositories.ListCommitComments method with 1207 | // the relevant owner and repo arguments. 1208 | func (c *Client) RepositoriesListCommitComments(ctx context.Context, sha string, opts *github.ListOptions) ([]*github.RepositoryComment, *github.Response, error) { 1209 | return c.Repositories.ListCommitComments(ctx, c.Owner, c.Project, sha, opts) 1210 | } 1211 | 1212 | // RepositoriesCreateComment calls the Repositories.CreateComment method with 1213 | // the relevant owner and repo arguments. 1214 | func (c *Client) RepositoriesCreateComment(ctx context.Context, sha string, comment *github.RepositoryComment) (*github.RepositoryComment, *github.Response, error) { 1215 | return c.Repositories.CreateComment(ctx, c.Owner, c.Project, sha, comment) 1216 | } 1217 | 1218 | // RepositoriesGetComment calls the Repositories.GetComment method with 1219 | // the relevant owner and repo arguments. 1220 | func (c *Client) RepositoriesGetComment(ctx context.Context, id int64) (*github.RepositoryComment, *github.Response, error) { 1221 | return c.Repositories.GetComment(ctx, c.Owner, c.Project, id) 1222 | } 1223 | 1224 | // RepositoriesUpdateComment calls the Repositories.UpdateComment method with 1225 | // the relevant owner and repo arguments. 1226 | func (c *Client) RepositoriesUpdateComment(ctx context.Context, id int64, comment *github.RepositoryComment) (*github.RepositoryComment, *github.Response, error) { 1227 | return c.Repositories.UpdateComment(ctx, c.Owner, c.Project, id, comment) 1228 | } 1229 | 1230 | // RepositoriesDeleteComment calls the Repositories.DeleteComment method with 1231 | // the relevant owner and repo arguments. 1232 | func (c *Client) RepositoriesDeleteComment(ctx context.Context, id int64) (*github.Response, error) { 1233 | return c.Repositories.DeleteComment(ctx, c.Owner, c.Project, id) 1234 | } 1235 | 1236 | // RepositoriesListCommits calls the Repositories.ListCommits method with 1237 | // the relevant owner and repo arguments. 1238 | func (c *Client) RepositoriesListCommits(ctx context.Context, opts *github.CommitsListOptions) ([]*github.RepositoryCommit, *github.Response, error) { 1239 | return c.Repositories.ListCommits(ctx, c.Owner, c.Project, opts) 1240 | } 1241 | 1242 | // RepositoriesGetCommit calls the Repositories.GetCommit method with 1243 | // the relevant owner and repo arguments. 1244 | func (c *Client) RepositoriesGetCommit(ctx context.Context, sha string) (*github.RepositoryCommit, *github.Response, error) { 1245 | return c.Repositories.GetCommit(ctx, c.Owner, c.Project, sha) 1246 | } 1247 | 1248 | // RepositoriesGetCommitRaw calls the Repositories.GetCommitRaw method with 1249 | // the relevant owner and repo arguments. 1250 | func (c *Client) RepositoriesGetCommitRaw(ctx context.Context, sha string, opts github.RawOptions) (string, *github.Response, error) { 1251 | return c.Repositories.GetCommitRaw(ctx, c.Owner, c.Project, sha, opts) 1252 | } 1253 | 1254 | // RepositoriesGetCommitSHA1 calls the Repositories.GetCommitSHA1 method with 1255 | // the relevant owner and repo arguments. 1256 | func (c *Client) RepositoriesGetCommitSHA1(ctx context.Context, ref string, lastSHA string) (string, *github.Response, error) { 1257 | return c.Repositories.GetCommitSHA1(ctx, c.Owner, c.Project, ref, lastSHA) 1258 | } 1259 | 1260 | // RepositoriesCompareCommits calls the Repositories.CompareCommits method with 1261 | // the relevant owner and repo arguments. 1262 | func (c *Client) RepositoriesCompareCommits(ctx context.Context, base string, head string) (*github.CommitsComparison, *github.Response, error) { 1263 | return c.Repositories.CompareCommits(ctx, c.Owner, c.Project, base, head) 1264 | } 1265 | 1266 | // RepositoriesListBranchesHeadCommit calls the Repositories.ListBranchesHeadCommit method with 1267 | // the relevant owner and repo arguments. 1268 | func (c *Client) RepositoriesListBranchesHeadCommit(ctx context.Context, sha string) ([]*github.BranchCommit, *github.Response, error) { 1269 | return c.Repositories.ListBranchesHeadCommit(ctx, c.Owner, c.Project, sha) 1270 | } 1271 | 1272 | // RepositoriesGetCommunityHealthMetrics calls the Repositories.GetCommunityHealthMetrics method with 1273 | // the relevant owner and repo arguments. 1274 | func (c *Client) RepositoriesGetCommunityHealthMetrics(ctx context.Context) (*github.CommunityHealthMetrics, *github.Response, error) { 1275 | return c.Repositories.GetCommunityHealthMetrics(ctx, c.Owner, c.Project) 1276 | } 1277 | 1278 | // RepositoriesGetReadme calls the Repositories.GetReadme method with 1279 | // the relevant owner and repo arguments. 1280 | func (c *Client) RepositoriesGetReadme(ctx context.Context, opts *github.RepositoryContentGetOptions) (*github.RepositoryContent, *github.Response, error) { 1281 | return c.Repositories.GetReadme(ctx, c.Owner, c.Project, opts) 1282 | } 1283 | 1284 | // RepositoriesDownloadContents calls the Repositories.DownloadContents method with 1285 | // the relevant owner and repo arguments. 1286 | func (c *Client) RepositoriesDownloadContents(ctx context.Context, filepath string, opts *github.RepositoryContentGetOptions) (io.ReadCloser, error) { 1287 | return c.Repositories.DownloadContents(ctx, c.Owner, c.Project, filepath, opts) 1288 | } 1289 | 1290 | // RepositoriesGetContents calls the Repositories.GetContents method with 1291 | // the relevant owner and repo arguments. 1292 | func (c *Client) RepositoriesGetContents(ctx context.Context, path string, opts *github.RepositoryContentGetOptions) (fileContent *github.RepositoryContent, directoryContent []*github.RepositoryContent, resp *github.Response, err error) { 1293 | return c.Repositories.GetContents(ctx, c.Owner, c.Project, path, opts) 1294 | } 1295 | 1296 | // RepositoriesCreateFile calls the Repositories.CreateFile method with 1297 | // the relevant owner and repo arguments. 1298 | func (c *Client) RepositoriesCreateFile(ctx context.Context, path string, opts *github.RepositoryContentFileOptions) (*github.RepositoryContentResponse, *github.Response, error) { 1299 | return c.Repositories.CreateFile(ctx, c.Owner, c.Project, path, opts) 1300 | } 1301 | 1302 | // RepositoriesUpdateFile calls the Repositories.UpdateFile method with 1303 | // the relevant owner and repo arguments. 1304 | func (c *Client) RepositoriesUpdateFile(ctx context.Context, path string, opts *github.RepositoryContentFileOptions) (*github.RepositoryContentResponse, *github.Response, error) { 1305 | return c.Repositories.UpdateFile(ctx, c.Owner, c.Project, path, opts) 1306 | } 1307 | 1308 | // RepositoriesDeleteFile calls the Repositories.DeleteFile method with 1309 | // the relevant owner and repo arguments. 1310 | func (c *Client) RepositoriesDeleteFile(ctx context.Context, path string, opts *github.RepositoryContentFileOptions) (*github.RepositoryContentResponse, *github.Response, error) { 1311 | return c.Repositories.DeleteFile(ctx, c.Owner, c.Project, path, opts) 1312 | } 1313 | 1314 | // RepositoriesListDeployments calls the Repositories.ListDeployments method with 1315 | // the relevant owner and repo arguments. 1316 | func (c *Client) RepositoriesListDeployments(ctx context.Context, opts *github.DeploymentsListOptions) ([]*github.Deployment, *github.Response, error) { 1317 | return c.Repositories.ListDeployments(ctx, c.Owner, c.Project, opts) 1318 | } 1319 | 1320 | // RepositoriesGetDeployment calls the Repositories.GetDeployment method with 1321 | // the relevant owner and repo arguments. 1322 | func (c *Client) RepositoriesGetDeployment(ctx context.Context, deploymentID int64) (*github.Deployment, *github.Response, error) { 1323 | return c.Repositories.GetDeployment(ctx, c.Owner, c.Project, deploymentID) 1324 | } 1325 | 1326 | // RepositoriesCreateDeployment calls the Repositories.CreateDeployment method with 1327 | // the relevant owner and repo arguments. 1328 | func (c *Client) RepositoriesCreateDeployment(ctx context.Context, request *github.DeploymentRequest) (*github.Deployment, *github.Response, error) { 1329 | return c.Repositories.CreateDeployment(ctx, c.Owner, c.Project, request) 1330 | } 1331 | 1332 | // RepositoriesListDeploymentStatuses calls the Repositories.ListDeploymentStatuses method with 1333 | // the relevant owner and repo arguments. 1334 | func (c *Client) RepositoriesListDeploymentStatuses(ctx context.Context, deployment int64, opts *github.ListOptions) ([]*github.DeploymentStatus, *github.Response, error) { 1335 | return c.Repositories.ListDeploymentStatuses(ctx, c.Owner, c.Project, deployment, opts) 1336 | } 1337 | 1338 | // RepositoriesGetDeploymentStatus calls the Repositories.GetDeploymentStatus method with 1339 | // the relevant owner and repo arguments. 1340 | func (c *Client) RepositoriesGetDeploymentStatus(ctx context.Context, deploymentID int64, deploymentStatusID int64) (*github.DeploymentStatus, *github.Response, error) { 1341 | return c.Repositories.GetDeploymentStatus(ctx, c.Owner, c.Project, deploymentID, deploymentStatusID) 1342 | } 1343 | 1344 | // RepositoriesCreateDeploymentStatus calls the Repositories.CreateDeploymentStatus method with 1345 | // the relevant owner and repo arguments. 1346 | func (c *Client) RepositoriesCreateDeploymentStatus(ctx context.Context, deployment int64, request *github.DeploymentStatusRequest) (*github.DeploymentStatus, *github.Response, error) { 1347 | return c.Repositories.CreateDeploymentStatus(ctx, c.Owner, c.Project, deployment, request) 1348 | } 1349 | 1350 | // RepositoriesListForks calls the Repositories.ListForks method with 1351 | // the relevant owner and repo arguments. 1352 | func (c *Client) RepositoriesListForks(ctx context.Context, opts *github.RepositoryListForksOptions) ([]*github.Repository, *github.Response, error) { 1353 | return c.Repositories.ListForks(ctx, c.Owner, c.Project, opts) 1354 | } 1355 | 1356 | // RepositoriesCreateFork calls the Repositories.CreateFork method with 1357 | // the relevant owner and repo arguments. 1358 | func (c *Client) RepositoriesCreateFork(ctx context.Context, opts *github.RepositoryCreateForkOptions) (*github.Repository, *github.Response, error) { 1359 | return c.Repositories.CreateFork(ctx, c.Owner, c.Project, opts) 1360 | } 1361 | 1362 | // RepositoriesCreateHook calls the Repositories.CreateHook method with 1363 | // the relevant owner and repo arguments. 1364 | func (c *Client) RepositoriesCreateHook(ctx context.Context, hook *github.Hook) (*github.Hook, *github.Response, error) { 1365 | return c.Repositories.CreateHook(ctx, c.Owner, c.Project, hook) 1366 | } 1367 | 1368 | // RepositoriesListHooks calls the Repositories.ListHooks method with 1369 | // the relevant owner and repo arguments. 1370 | func (c *Client) RepositoriesListHooks(ctx context.Context, opts *github.ListOptions) ([]*github.Hook, *github.Response, error) { 1371 | return c.Repositories.ListHooks(ctx, c.Owner, c.Project, opts) 1372 | } 1373 | 1374 | // RepositoriesGetHook calls the Repositories.GetHook method with 1375 | // the relevant owner and repo arguments. 1376 | func (c *Client) RepositoriesGetHook(ctx context.Context, id int64) (*github.Hook, *github.Response, error) { 1377 | return c.Repositories.GetHook(ctx, c.Owner, c.Project, id) 1378 | } 1379 | 1380 | // RepositoriesEditHook calls the Repositories.EditHook method with 1381 | // the relevant owner and repo arguments. 1382 | func (c *Client) RepositoriesEditHook(ctx context.Context, id int64, hook *github.Hook) (*github.Hook, *github.Response, error) { 1383 | return c.Repositories.EditHook(ctx, c.Owner, c.Project, id, hook) 1384 | } 1385 | 1386 | // RepositoriesDeleteHook calls the Repositories.DeleteHook method with 1387 | // the relevant owner and repo arguments. 1388 | func (c *Client) RepositoriesDeleteHook(ctx context.Context, id int64) (*github.Response, error) { 1389 | return c.Repositories.DeleteHook(ctx, c.Owner, c.Project, id) 1390 | } 1391 | 1392 | // RepositoriesPingHook calls the Repositories.PingHook method with 1393 | // the relevant owner and repo arguments. 1394 | func (c *Client) RepositoriesPingHook(ctx context.Context, id int64) (*github.Response, error) { 1395 | return c.Repositories.PingHook(ctx, c.Owner, c.Project, id) 1396 | } 1397 | 1398 | // RepositoriesTestHook calls the Repositories.TestHook method with 1399 | // the relevant owner and repo arguments. 1400 | func (c *Client) RepositoriesTestHook(ctx context.Context, id int64) (*github.Response, error) { 1401 | return c.Repositories.TestHook(ctx, c.Owner, c.Project, id) 1402 | } 1403 | 1404 | // RepositoriesListInvitations calls the Repositories.ListInvitations method with 1405 | // the relevant owner and repo arguments. 1406 | func (c *Client) RepositoriesListInvitations(ctx context.Context, opts *github.ListOptions) ([]*github.RepositoryInvitation, *github.Response, error) { 1407 | return c.Repositories.ListInvitations(ctx, c.Owner, c.Project, opts) 1408 | } 1409 | 1410 | // RepositoriesDeleteInvitation calls the Repositories.DeleteInvitation method with 1411 | // the relevant owner and repo arguments. 1412 | func (c *Client) RepositoriesDeleteInvitation(ctx context.Context, invitationID int64) (*github.Response, error) { 1413 | return c.Repositories.DeleteInvitation(ctx, c.Owner, c.Project, invitationID) 1414 | } 1415 | 1416 | // RepositoriesUpdateInvitation calls the Repositories.UpdateInvitation method with 1417 | // the relevant owner and repo arguments. 1418 | func (c *Client) RepositoriesUpdateInvitation(ctx context.Context, invitationID int64, permissions string) (*github.RepositoryInvitation, *github.Response, error) { 1419 | return c.Repositories.UpdateInvitation(ctx, c.Owner, c.Project, invitationID, permissions) 1420 | } 1421 | 1422 | // RepositoriesListKeys calls the Repositories.ListKeys method with 1423 | // the relevant owner and repo arguments. 1424 | func (c *Client) RepositoriesListKeys(ctx context.Context, opts *github.ListOptions) ([]*github.Key, *github.Response, error) { 1425 | return c.Repositories.ListKeys(ctx, c.Owner, c.Project, opts) 1426 | } 1427 | 1428 | // RepositoriesGetKey calls the Repositories.GetKey method with 1429 | // the relevant owner and repo arguments. 1430 | func (c *Client) RepositoriesGetKey(ctx context.Context, id int64) (*github.Key, *github.Response, error) { 1431 | return c.Repositories.GetKey(ctx, c.Owner, c.Project, id) 1432 | } 1433 | 1434 | // RepositoriesCreateKey calls the Repositories.CreateKey method with 1435 | // the relevant owner and repo arguments. 1436 | func (c *Client) RepositoriesCreateKey(ctx context.Context, key *github.Key) (*github.Key, *github.Response, error) { 1437 | return c.Repositories.CreateKey(ctx, c.Owner, c.Project, key) 1438 | } 1439 | 1440 | // RepositoriesDeleteKey calls the Repositories.DeleteKey method with 1441 | // the relevant owner and repo arguments. 1442 | func (c *Client) RepositoriesDeleteKey(ctx context.Context, id int64) (*github.Response, error) { 1443 | return c.Repositories.DeleteKey(ctx, c.Owner, c.Project, id) 1444 | } 1445 | 1446 | // RepositoriesMerge calls the Repositories.Merge method with 1447 | // the relevant owner and repo arguments. 1448 | func (c *Client) RepositoriesMerge(ctx context.Context, request *github.RepositoryMergeRequest) (*github.RepositoryCommit, *github.Response, error) { 1449 | return c.Repositories.Merge(ctx, c.Owner, c.Project, request) 1450 | } 1451 | 1452 | // RepositoriesEnablePages calls the Repositories.EnablePages method with 1453 | // the relevant owner and repo arguments. 1454 | func (c *Client) RepositoriesEnablePages(ctx context.Context, pages *github.Pages) (*github.Pages, *github.Response, error) { 1455 | return c.Repositories.EnablePages(ctx, c.Owner, c.Project, pages) 1456 | } 1457 | 1458 | // RepositoriesUpdatePages calls the Repositories.UpdatePages method with 1459 | // the relevant owner and repo arguments. 1460 | func (c *Client) RepositoriesUpdatePages(ctx context.Context, opts *github.PagesUpdate) (*github.Response, error) { 1461 | return c.Repositories.UpdatePages(ctx, c.Owner, c.Project, opts) 1462 | } 1463 | 1464 | // RepositoriesDisablePages calls the Repositories.DisablePages method with 1465 | // the relevant owner and repo arguments. 1466 | func (c *Client) RepositoriesDisablePages(ctx context.Context) (*github.Response, error) { 1467 | return c.Repositories.DisablePages(ctx, c.Owner, c.Project) 1468 | } 1469 | 1470 | // RepositoriesGetPagesInfo calls the Repositories.GetPagesInfo method with 1471 | // the relevant owner and repo arguments. 1472 | func (c *Client) RepositoriesGetPagesInfo(ctx context.Context) (*github.Pages, *github.Response, error) { 1473 | return c.Repositories.GetPagesInfo(ctx, c.Owner, c.Project) 1474 | } 1475 | 1476 | // RepositoriesListPagesBuilds calls the Repositories.ListPagesBuilds method with 1477 | // the relevant owner and repo arguments. 1478 | func (c *Client) RepositoriesListPagesBuilds(ctx context.Context, opts *github.ListOptions) ([]*github.PagesBuild, *github.Response, error) { 1479 | return c.Repositories.ListPagesBuilds(ctx, c.Owner, c.Project, opts) 1480 | } 1481 | 1482 | // RepositoriesGetLatestPagesBuild calls the Repositories.GetLatestPagesBuild method with 1483 | // the relevant owner and repo arguments. 1484 | func (c *Client) RepositoriesGetLatestPagesBuild(ctx context.Context) (*github.PagesBuild, *github.Response, error) { 1485 | return c.Repositories.GetLatestPagesBuild(ctx, c.Owner, c.Project) 1486 | } 1487 | 1488 | // RepositoriesGetPageBuild calls the Repositories.GetPageBuild method with 1489 | // the relevant owner and repo arguments. 1490 | func (c *Client) RepositoriesGetPageBuild(ctx context.Context, id int64) (*github.PagesBuild, *github.Response, error) { 1491 | return c.Repositories.GetPageBuild(ctx, c.Owner, c.Project, id) 1492 | } 1493 | 1494 | // RepositoriesRequestPageBuild calls the Repositories.RequestPageBuild method with 1495 | // the relevant owner and repo arguments. 1496 | func (c *Client) RepositoriesRequestPageBuild(ctx context.Context) (*github.PagesBuild, *github.Response, error) { 1497 | return c.Repositories.RequestPageBuild(ctx, c.Owner, c.Project) 1498 | } 1499 | 1500 | // RepositoriesListPreReceiveHooks calls the Repositories.ListPreReceiveHooks method with 1501 | // the relevant owner and repo arguments. 1502 | func (c *Client) RepositoriesListPreReceiveHooks(ctx context.Context, opts *github.ListOptions) ([]*github.PreReceiveHook, *github.Response, error) { 1503 | return c.Repositories.ListPreReceiveHooks(ctx, c.Owner, c.Project, opts) 1504 | } 1505 | 1506 | // RepositoriesGetPreReceiveHook calls the Repositories.GetPreReceiveHook method with 1507 | // the relevant owner and repo arguments. 1508 | func (c *Client) RepositoriesGetPreReceiveHook(ctx context.Context, id int64) (*github.PreReceiveHook, *github.Response, error) { 1509 | return c.Repositories.GetPreReceiveHook(ctx, c.Owner, c.Project, id) 1510 | } 1511 | 1512 | // RepositoriesUpdatePreReceiveHook calls the Repositories.UpdatePreReceiveHook method with 1513 | // the relevant owner and repo arguments. 1514 | func (c *Client) RepositoriesUpdatePreReceiveHook(ctx context.Context, id int64, hook *github.PreReceiveHook) (*github.PreReceiveHook, *github.Response, error) { 1515 | return c.Repositories.UpdatePreReceiveHook(ctx, c.Owner, c.Project, id, hook) 1516 | } 1517 | 1518 | // RepositoriesDeletePreReceiveHook calls the Repositories.DeletePreReceiveHook method with 1519 | // the relevant owner and repo arguments. 1520 | func (c *Client) RepositoriesDeletePreReceiveHook(ctx context.Context, id int64) (*github.Response, error) { 1521 | return c.Repositories.DeletePreReceiveHook(ctx, c.Owner, c.Project, id) 1522 | } 1523 | 1524 | // RepositoriesListProjects calls the Repositories.ListProjects method with 1525 | // the relevant owner and repo arguments. 1526 | func (c *Client) RepositoriesListProjects(ctx context.Context, opts *github.ProjectListOptions) ([]*github.Project, *github.Response, error) { 1527 | return c.Repositories.ListProjects(ctx, c.Owner, c.Project, opts) 1528 | } 1529 | 1530 | // RepositoriesCreateProject calls the Repositories.CreateProject method with 1531 | // the relevant owner and repo arguments. 1532 | func (c *Client) RepositoriesCreateProject(ctx context.Context, opts *github.ProjectOptions) (*github.Project, *github.Response, error) { 1533 | return c.Repositories.CreateProject(ctx, c.Owner, c.Project, opts) 1534 | } 1535 | 1536 | // RepositoriesListReleases calls the Repositories.ListReleases method with 1537 | // the relevant owner and repo arguments. 1538 | func (c *Client) RepositoriesListReleases(ctx context.Context, opts *github.ListOptions) ([]*github.RepositoryRelease, *github.Response, error) { 1539 | return c.Repositories.ListReleases(ctx, c.Owner, c.Project, opts) 1540 | } 1541 | 1542 | // RepositoriesGetRelease calls the Repositories.GetRelease method with 1543 | // the relevant owner and repo arguments. 1544 | func (c *Client) RepositoriesGetRelease(ctx context.Context, id int64) (*github.RepositoryRelease, *github.Response, error) { 1545 | return c.Repositories.GetRelease(ctx, c.Owner, c.Project, id) 1546 | } 1547 | 1548 | // RepositoriesGetLatestRelease calls the Repositories.GetLatestRelease method with 1549 | // the relevant owner and repo arguments. 1550 | func (c *Client) RepositoriesGetLatestRelease(ctx context.Context) (*github.RepositoryRelease, *github.Response, error) { 1551 | return c.Repositories.GetLatestRelease(ctx, c.Owner, c.Project) 1552 | } 1553 | 1554 | // RepositoriesGetReleaseByTag calls the Repositories.GetReleaseByTag method with 1555 | // the relevant owner and repo arguments. 1556 | func (c *Client) RepositoriesGetReleaseByTag(ctx context.Context, tag string) (*github.RepositoryRelease, *github.Response, error) { 1557 | return c.Repositories.GetReleaseByTag(ctx, c.Owner, c.Project, tag) 1558 | } 1559 | 1560 | // RepositoriesCreateRelease calls the Repositories.CreateRelease method with 1561 | // the relevant owner and repo arguments. 1562 | func (c *Client) RepositoriesCreateRelease(ctx context.Context, release *github.RepositoryRelease) (*github.RepositoryRelease, *github.Response, error) { 1563 | return c.Repositories.CreateRelease(ctx, c.Owner, c.Project, release) 1564 | } 1565 | 1566 | // RepositoriesEditRelease calls the Repositories.EditRelease method with 1567 | // the relevant owner and repo arguments. 1568 | func (c *Client) RepositoriesEditRelease(ctx context.Context, id int64, release *github.RepositoryRelease) (*github.RepositoryRelease, *github.Response, error) { 1569 | return c.Repositories.EditRelease(ctx, c.Owner, c.Project, id, release) 1570 | } 1571 | 1572 | // RepositoriesDeleteRelease calls the Repositories.DeleteRelease method with 1573 | // the relevant owner and repo arguments. 1574 | func (c *Client) RepositoriesDeleteRelease(ctx context.Context, id int64) (*github.Response, error) { 1575 | return c.Repositories.DeleteRelease(ctx, c.Owner, c.Project, id) 1576 | } 1577 | 1578 | // RepositoriesListReleaseAssets calls the Repositories.ListReleaseAssets method with 1579 | // the relevant owner and repo arguments. 1580 | func (c *Client) RepositoriesListReleaseAssets(ctx context.Context, id int64, opts *github.ListOptions) ([]*github.ReleaseAsset, *github.Response, error) { 1581 | return c.Repositories.ListReleaseAssets(ctx, c.Owner, c.Project, id, opts) 1582 | } 1583 | 1584 | // RepositoriesGetReleaseAsset calls the Repositories.GetReleaseAsset method with 1585 | // the relevant owner and repo arguments. 1586 | func (c *Client) RepositoriesGetReleaseAsset(ctx context.Context, id int64) (*github.ReleaseAsset, *github.Response, error) { 1587 | return c.Repositories.GetReleaseAsset(ctx, c.Owner, c.Project, id) 1588 | } 1589 | 1590 | // RepositoriesDownloadReleaseAsset calls the Repositories.DownloadReleaseAsset method with 1591 | // the relevant owner and repo arguments. 1592 | func (c *Client) RepositoriesDownloadReleaseAsset(ctx context.Context, id int64, followRedirectsClient *http.Client) (rc io.ReadCloser, redirectURL string, err error) { 1593 | return c.Repositories.DownloadReleaseAsset(ctx, c.Owner, c.Project, id, followRedirectsClient) 1594 | } 1595 | 1596 | // RepositoriesEditReleaseAsset calls the Repositories.EditReleaseAsset method with 1597 | // the relevant owner and repo arguments. 1598 | func (c *Client) RepositoriesEditReleaseAsset(ctx context.Context, id int64, release *github.ReleaseAsset) (*github.ReleaseAsset, *github.Response, error) { 1599 | return c.Repositories.EditReleaseAsset(ctx, c.Owner, c.Project, id, release) 1600 | } 1601 | 1602 | // RepositoriesDeleteReleaseAsset calls the Repositories.DeleteReleaseAsset method with 1603 | // the relevant owner and repo arguments. 1604 | func (c *Client) RepositoriesDeleteReleaseAsset(ctx context.Context, id int64) (*github.Response, error) { 1605 | return c.Repositories.DeleteReleaseAsset(ctx, c.Owner, c.Project, id) 1606 | } 1607 | 1608 | // RepositoriesUploadReleaseAsset calls the Repositories.UploadReleaseAsset method with 1609 | // the relevant owner and repo arguments. 1610 | func (c *Client) RepositoriesUploadReleaseAsset(ctx context.Context, id int64, opts *github.UploadOptions, file *os.File) (*github.ReleaseAsset, *github.Response, error) { 1611 | return c.Repositories.UploadReleaseAsset(ctx, c.Owner, c.Project, id, opts, file) 1612 | } 1613 | 1614 | // RepositoriesListContributorsStats calls the Repositories.ListContributorsStats method with 1615 | // the relevant owner and repo arguments. 1616 | func (c *Client) RepositoriesListContributorsStats(ctx context.Context) ([]*github.ContributorStats, *github.Response, error) { 1617 | return c.Repositories.ListContributorsStats(ctx, c.Owner, c.Project) 1618 | } 1619 | 1620 | // RepositoriesListCommitActivity calls the Repositories.ListCommitActivity method with 1621 | // the relevant owner and repo arguments. 1622 | func (c *Client) RepositoriesListCommitActivity(ctx context.Context) ([]*github.WeeklyCommitActivity, *github.Response, error) { 1623 | return c.Repositories.ListCommitActivity(ctx, c.Owner, c.Project) 1624 | } 1625 | 1626 | // RepositoriesListCodeFrequency calls the Repositories.ListCodeFrequency method with 1627 | // the relevant owner and repo arguments. 1628 | func (c *Client) RepositoriesListCodeFrequency(ctx context.Context) ([]*github.WeeklyStats, *github.Response, error) { 1629 | return c.Repositories.ListCodeFrequency(ctx, c.Owner, c.Project) 1630 | } 1631 | 1632 | // RepositoriesListParticipation calls the Repositories.ListParticipation method with 1633 | // the relevant owner and repo arguments. 1634 | func (c *Client) RepositoriesListParticipation(ctx context.Context) (*github.RepositoryParticipation, *github.Response, error) { 1635 | return c.Repositories.ListParticipation(ctx, c.Owner, c.Project) 1636 | } 1637 | 1638 | // RepositoriesListPunchCard calls the Repositories.ListPunchCard method with 1639 | // the relevant owner and repo arguments. 1640 | func (c *Client) RepositoriesListPunchCard(ctx context.Context) ([]*github.PunchCard, *github.Response, error) { 1641 | return c.Repositories.ListPunchCard(ctx, c.Owner, c.Project) 1642 | } 1643 | 1644 | // RepositoriesListStatuses calls the Repositories.ListStatuses method with 1645 | // the relevant owner and repo arguments. 1646 | func (c *Client) RepositoriesListStatuses(ctx context.Context, ref string, opts *github.ListOptions) ([]*github.RepoStatus, *github.Response, error) { 1647 | return c.Repositories.ListStatuses(ctx, c.Owner, c.Project, ref, opts) 1648 | } 1649 | 1650 | // RepositoriesCreateStatus calls the Repositories.CreateStatus method with 1651 | // the relevant owner and repo arguments. 1652 | func (c *Client) RepositoriesCreateStatus(ctx context.Context, ref string, status *github.RepoStatus) (*github.RepoStatus, *github.Response, error) { 1653 | return c.Repositories.CreateStatus(ctx, c.Owner, c.Project, ref, status) 1654 | } 1655 | 1656 | // RepositoriesGetCombinedStatus calls the Repositories.GetCombinedStatus method with 1657 | // the relevant owner and repo arguments. 1658 | func (c *Client) RepositoriesGetCombinedStatus(ctx context.Context, ref string, opts *github.ListOptions) (*github.CombinedStatus, *github.Response, error) { 1659 | return c.Repositories.GetCombinedStatus(ctx, c.Owner, c.Project, ref, opts) 1660 | } 1661 | 1662 | // RepositoriesListTrafficReferrers calls the Repositories.ListTrafficReferrers method with 1663 | // the relevant owner and repo arguments. 1664 | func (c *Client) RepositoriesListTrafficReferrers(ctx context.Context) ([]*github.TrafficReferrer, *github.Response, error) { 1665 | return c.Repositories.ListTrafficReferrers(ctx, c.Owner, c.Project) 1666 | } 1667 | 1668 | // RepositoriesListTrafficPaths calls the Repositories.ListTrafficPaths method with 1669 | // the relevant owner and repo arguments. 1670 | func (c *Client) RepositoriesListTrafficPaths(ctx context.Context) ([]*github.TrafficPath, *github.Response, error) { 1671 | return c.Repositories.ListTrafficPaths(ctx, c.Owner, c.Project) 1672 | } 1673 | 1674 | // RepositoriesListTrafficViews calls the Repositories.ListTrafficViews method with 1675 | // the relevant owner and repo arguments. 1676 | func (c *Client) RepositoriesListTrafficViews(ctx context.Context, opts *github.TrafficBreakdownOptions) (*github.TrafficViews, *github.Response, error) { 1677 | return c.Repositories.ListTrafficViews(ctx, c.Owner, c.Project, opts) 1678 | } 1679 | 1680 | // RepositoriesListTrafficClones calls the Repositories.ListTrafficClones method with 1681 | // the relevant owner and repo arguments. 1682 | func (c *Client) RepositoriesListTrafficClones(ctx context.Context, opts *github.TrafficBreakdownOptions) (*github.TrafficClones, *github.Response, error) { 1683 | return c.Repositories.ListTrafficClones(ctx, c.Owner, c.Project, opts) 1684 | } 1685 | --------------------------------------------------------------------------------