Skip to content

Commit

Permalink
chore: update golang version(v1.16 -> v1.20) & exchange log to fmt an…
Browse files Browse the repository at this point in the history
…d panic (abema#34)
  • Loading branch information
Reimei1213 authored Jul 14, 2023
1 parent 7086436 commit 487288a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: set up
uses: actions/setup-go@v1
with:
go-version: 1.16
go-version: 1.20
- name: checkout
uses: actions/checkout@v1
- name: cache
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16-alpine AS builder
FROM golang:1.20-alpine AS builder
WORKDIR /app
COPY go.mod ./
COPY go.sum ./
Expand Down
11 changes: 9 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
module github.com/abema/github-actions-merger

go 1.16
go 1.20

require (
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.1.0 // indirect
github.com/kelseyhightower/envconfig v1.4.0
golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1
)

require (
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-querystring v1.1.0 // indirect
golang.org/x/net v0.0.0-20200822124328-c89045814202 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)
21 changes: 13 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"log"
"regexp"
"strings"
"text/template"
Expand Down Expand Up @@ -35,28 +34,34 @@ func main() {
var e env
err := envconfig.Process("INPUT", &e)
if err != nil {
log.Fatal(err.Error())
fmt.Printf("failed to load inputs: %s\n", err.Error())
panic(err.Error())
}
ctx, f := context.WithTimeout(context.Background(), jobTimeout)
defer f()
client := newGHClient(e.GithubToken)
if err := validateEnv(e); err != nil {
if serr := client.sendMsg(ctx, e.Owner, e.Repo, e.PRNumber, errMsg(err)); serr != nil {
log.Fatalf("failed to send message: %v original: %v", serr, err)
fmt.Printf("failed to send message: %v original: %v", serr, err)
panic(serr.Error())
}
log.Fatal(err.Error())
fmt.Printf("failed to validate env: %v", err)
panic(err.Error())
}
if err := client.merge(ctx, e.Owner, e.Repo, e.PRNumber, e.MergeMethod); err != nil {
if serr := client.sendMsg(ctx, e.Owner, e.Repo, e.PRNumber, errMsg(err)); serr != nil {
log.Fatalf("failed to send message: %v original: %v", serr, err)
fmt.Printf("failed to send message: %v original: %v", serr, err)
panic(serr.Error())
}
log.Fatal(err.Error())
fmt.Printf("failed to merge: %v", err)
panic(err.Error())
}
successMsg := "Merged PR #" + fmt.Sprintf("%d", e.PRNumber) + " successfully!"
if err := client.sendMsg(ctx, e.Owner, e.Repo, e.PRNumber, successMsg); err != nil {
log.Fatal(err.Error())
fmt.Printf("failed to send message: %v", err)
panic(err.Error())
}
log.Printf(successMsg)
fmt.Printf(successMsg)
}

func validateEnv(e env) error {
Expand Down

0 comments on commit 487288a

Please sign in to comment.