Skip to content

Commit

Permalink
chore: set env & add message (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reimei1213 authored Jul 20, 2023
1 parent 4102e68 commit a986be8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"os"
"os/exec"
"regexp"
"strconv"
Expand Down Expand Up @@ -40,6 +41,12 @@ func main() {
fmt.Printf("failed to load inputs: %s\n", err.Error())
panic(err.Error())
}
err = os.Setenv("GITHUB_TOKEN", e.GithubToken)
if err != nil {
fmt.Printf("failed to set env: %s\n", err.Error())
panic(err.Error())
}

ctx, f := context.WithTimeout(context.Background(), jobTimeout)
defer f()
client := newGHClient(e.GithubToken)
Expand All @@ -59,7 +66,12 @@ func main() {
fmt.Printf("failed to merge: %v", err)
panic(err.Error())
}
successMsg := "Merged PR #" + fmt.Sprintf("%d", e.PRNumber) + " successfully!"
var successMsg string
if e.EnableAutoMerge {
successMsg = "Enabled auto merge #" + fmt.Sprintf("%d", e.PRNumber) + " \nIf CI fails, fix problems and retry."
} else {
successMsg = "Merged PR #" + fmt.Sprintf("%d", e.PRNumber) + " successfully!"
}
if err := client.sendMsg(ctx, e.Owner, e.Repo, e.PRNumber, successMsg); err != nil {
fmt.Printf("failed to send message: %v", err)
panic(err.Error())
Expand Down

0 comments on commit a986be8

Please sign in to comment.