Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PullRequestTargetEvent (fixes #13) #27

Merged
merged 2 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Version: 1
Labels:
- Label: "TestLabel"
version: 1
labels:
- label: "TestLabel"
title: ".*"
- Label: "TestFileMatch"
- label: "TestFileMatch"
files:
- "cmd/.*.go"
- "pkg/.*.go"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Label PRs

on:
- pull_request
pull_request:

jobs:
build:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
Then add a new file `.github/labeler.yml` with the configuration as
described below in the `Configuration` section.

If you want to run the action on the base of the pull request, rather
than on the merge commit, you should trigger the action on
`pull_request_target`. Check the [GitHub
documentation](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target)
for more details.

This action will avoid failing in all cases, so if you're experiencing
unexpected behaviour it's worth looking at execution logs just in case.
Typical errors are:
Expand Down
2 changes: 1 addition & 1 deletion cmd/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/go-yaml/yaml"
"github.com/google/go-github/v27/github"
"github.com/google/go-github/v35/github"
labeler "github.com/srvaroa/labeler/pkg"
"golang.org/x/oauth2"
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.12
require (
github.com/go-yaml/yaml v2.1.0+incompatible
github.com/google/go-cmp v0.3.1
github.com/google/go-github/v27 v27.0.6
github.com/google/go-github/v35 v35.0.0
github.com/kr/pretty v0.1.0 // indirect
github.com/waigani/diffparser v0.0.0-20190828052634-7391f219313d
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwn
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-github/v27 v27.0.6 h1:oiOZuBmGHvrGM1X9uNUAUlLgp5r1UUO/M/KnbHnLRlQ=
github.com/google/go-github/v27 v27.0.6/go.mod h1:/0Gr8pJ55COkmv+S/yPKCczSkUPIM/LnFyubufRNIS0=
github.com/google/go-github/v35 v35.0.0 h1:oLrHdYkSQvbhN4gJihpEkTFKAZnIFgTCj1p/OlE4Os4=
github.com/google/go-github/v35 v35.0.0/go.mod h1:s0515YVTI+IMrDoy9Y4pHt9ShGpzHvHO8rZ7L7acgvs=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
Expand Down
4 changes: 3 additions & 1 deletion pkg/labeler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strconv"
"strings"

gh "github.com/google/go-github/v27/github"
gh "github.com/google/go-github/v35/github"
"github.com/waigani/diffparser"
)

Expand Down Expand Up @@ -195,6 +195,8 @@ func (l *Labeler) HandleEvent(
switch event := event.(type) {
case *gh.PullRequestEvent:
err = l.ExecuteOn(event.PullRequest)
case *gh.PullRequestTargetEvent:
err = l.ExecuteOn(event.PullRequest)
}
return err
}
Expand Down