/
close-pr.go
34 lines (28 loc) · 949 Bytes
/
close-pr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"github.com/google/go-github/github"
client "github.com/jackstockley89/github-actions/github-api/client"
pullrequestinfo "github.com/jackstockley89/github-actions/github-api/pull-request-info"
)
func PullRequestClose() {
flag.Parse()
token := flag.String("token", os.Getenv("GITHUB_TOKEN"), "GihHub Personel token string")
githubrepo := flag.String("githubrepo", os.Getenv("GITHUB_REPOSITORY"), "Github Repository string")
githubref := flag.String("githubref", os.Getenv("GITHUB_REF"), "Github Respository PR ref string")
c := client.ClientConnect(*token)
pri := pullrequestinfo.PullRequestData(*githubrepo, *githubref)
state := &github.PullRequest{State: github.String("closed")}
prs, _, err := c.PullRequests.Edit(context.Background(), pri.Owner, pri.Repository, pri.Bid, state)
if err != nil {
log.Fatal()
}
fmt.Println(prs)
}
func main() {
PullRequestClose()
}