Skip to content

Commit

Permalink
Improve PR Update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer committed Oct 12, 2024
1 parent 86706f7 commit 0c39b24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ jobs:
id: refs
run: |
set -ex
go run ./cmd/build inspect-pr-action --log.colorMode=always "${{github.event.action}}" "${{github.event.label.name}}"
go run ./cmd/build inspect-pr-action --log.colorMode=always "${{github.event.action}}" "${{github.event.number}}" "${{github.event.label.name}}"
14 changes: 10 additions & 4 deletions cmd/build/repo-prs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,29 @@ func (this *repoPrs) init(ctx context.Context, app *kingpin.Application) {
StringVar(&this.testPublishLabel)

var eventAction string
var prNumber uint
var label string

cmdIu := app.Command("inspect-pr-action", "")
cmdIu.Arg("eventAction", "").
Required().
StringVar(&eventAction)
cmdIu.Arg("prNumber", "").
Required().
UintVar(&prNumber)
cmdIu.Arg("label", "").
StringVar(&label)
cmdIu.Action(func(*kingpin.ParseContext) error {
return this.inspectAction(ctx, eventAction, label)
return this.inspectAction(ctx, eventAction, prNumber, label)
})
}

func (this *repoPrs) inspectAction(ctx context.Context, eventAction string, label string) error {
prNumber := this.pr()
func (this *repoPrs) inspectAction(ctx context.Context, eventAction string, prNumber uint, label string) error {
if prNumber == 0 {
prNumber = this.pr()
}
if prNumber == 0 {
return fmt.Errorf("the environment does not contain a pr reference")
return fmt.Errorf("neither the environment does not contain a pr reference nor the command was called with it")
}

pr, err := this.byId(ctx, prNumber)
Expand Down

0 comments on commit 0c39b24

Please sign in to comment.