-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ded33b4
commit 6484755
Showing
176 changed files
with
54,876 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM golang:1.11-alpine | ||
|
||
LABEL "com.github.actions.name"="Auto Close" | ||
LABEL "com.github.actions.description"="Auto close pull requests" | ||
LABEL "com.github.actions.icon"="slash" | ||
LABEL "com.github.actions.color"="red" | ||
|
||
WORKDIR $GOPATH/src/github.com/superbrothers/auto-close-action | ||
COPY . . | ||
RUN set -x && go build -o /action | ||
|
||
ENTRYPOINT ["/action"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
# | ||
# [prune] | ||
# non-go = false | ||
# go-tests = true | ||
# unused-packages = true | ||
|
||
[[constraint]] | ||
name = "github.com/google/go-github" | ||
version ="v24.0.0" | ||
|
||
[[constraint]] | ||
name = "golang.org/x/oauth2" | ||
branch = "master" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Kazuki Suda <kazuki.suda@gmail.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
REPO := superbrothers/auto-close-action | ||
|
||
.PHONY: image | ||
image: | ||
docker build -t $(REPO) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# :no_entry_sign: Auto close pull requests GitHub Action | ||
|
||
A GitHub Action to automatically close pull requests. | ||
|
||
## Usage | ||
|
||
This Action subscribes to `pull_request` events. When receiving a `pull_request` event, this action close the pull request triggered by the event immediately. | ||
|
||
```workflow | ||
workflow "New workflow" { | ||
on = "pull_request" | ||
resolves = ["Auto Close"] | ||
} | ||
action "Auto Close" { | ||
uses = "superbrothers/auto-close-action" | ||
env = { | ||
# Optional. Post a issue comment just before closing a pull request. | ||
COMMENT = "We do not accept PRs. If you have any questions, please feel free to connect us." | ||
} | ||
secrets = ["GITHUB_TOKEN"] | ||
} | ||
``` | ||
|
||
<img src="./docs/auto-close-action.png" width="400px"> | ||
|
||
## Environment variables | ||
|
||
- `COMMENT` - *Optional*. Post an issue comment just before closing a pull request. | ||
|
||
## LICENSE | ||
|
||
This software is released under the MIT License. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
"os" | ||
"strings" | ||
|
||
"github.com/google/go-github/github" | ||
"golang.org/x/oauth2" | ||
) | ||
|
||
func main() { | ||
eventName := os.Getenv("GITHUB_EVENT_NAME") | ||
if eventName != "pull_request" { | ||
fmt.Printf("Ignoring event %s (only listens for 'pull_request')\n", eventName) | ||
return | ||
} | ||
|
||
ctx := context.Background() | ||
client := newClient(ctx) | ||
|
||
f, err := os.Open(os.Getenv("GITHUB_EVENT_PATH")) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
decorder := json.NewDecoder(f) | ||
var triggerEvent github.PullRequestEvent | ||
if err := decorder.Decode(&triggerEvent); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
fullRepo := os.Getenv("GITHUB_REPOSITORY") | ||
repo := strings.SplitN(fullRepo, "/", 2) | ||
if len(repo) != 2 { | ||
log.Fatalf("Invalid repo name: %s\n", fullRepo) | ||
} | ||
|
||
number := *triggerEvent.Number | ||
|
||
body := os.Getenv("COMMENT") | ||
if len(body) > 0 { | ||
issueComment := &github.IssueComment{Body: &body} | ||
_, _, err = client.Issues.CreateComment(ctx, repo[0], repo[1], number, issueComment) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
|
||
state := "closed" | ||
pr := &github.PullRequest{State: &state} | ||
_, _, err = client.PullRequests.Edit(ctx, repo[0], repo[1], number, pr) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Printf("Closed PR %d\n", number) | ||
} | ||
|
||
func newClient(ctx context.Context) *github.Client { | ||
token := os.Getenv("GITHUB_TOKEN") | ||
|
||
ts := oauth2.StaticTokenSource( | ||
&oauth2.Token{AccessToken: token}, | ||
) | ||
tc := oauth2.NewClient(ctx, ts) | ||
|
||
return github.NewClient(tc) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.