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

[FIX] get newest release instead of oldest (also bump deps) #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.14 as builder
FROM golang:1.20 as builder

ADD . /go/src/github.com/justwatchcom/github-releases-notifier
WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier

RUN make build

FROM alpine:3.11
FROM alpine:3.18
RUN apk --no-cache add ca-certificates

COPY --from=builder /go/src/github.com/justwatchcom/github-releases-notifier /bin/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To watch repositories simply add them to the list of arguments `-r=kubernetes/ku
### Deploying

1. Get a URL to send WebHooks to your Slack from https://api.slack.com/incoming-webhooks.
2. Get a token for scraping GitHub: [https://help.github.com/](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line).
2. [Get a token](https://github.com/settings/tokens) for scraping GitHub: [https://help.github.com/](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line). For public repositories add the `repo > public_repo` permission.

#### Docker

Expand All @@ -42,4 +42,4 @@ After creating the secret with your credentials you can apply the deployment:

`kubectl apply -f deployments/kubernetes.yml`

That's it.
That's it.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
0.0.2
24 changes: 17 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
module github.com/marthjod/github-releases-notifier

go 1.14
go 1.20

require (
github.com/alexflint/go-arg v1.3.0
github.com/go-kit/kit v0.10.0
github.com/joho/godotenv v1.3.0
github.com/shurcooL/githubql v0.0.0-20191127044304-8f68eb5628d0
github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
github.com/alexflint/go-arg v1.4.3
github.com/go-kit/log v0.2.1
github.com/joho/godotenv v1.5.1
github.com/shurcooL/githubv4 v0.0.0-20230424031643-6cea62ecd5a9
golang.org/x/oauth2 v0.8.0
)

require (
github.com/alexflint/go-scalar v1.2.0 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29 // indirect
golang.org/x/net v0.10.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
389 changes: 38 additions & 351 deletions go.sum

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"time"

"github.com/alexflint/go-arg"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/joho/godotenv"
githubql "github.com/shurcooL/githubql"

"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
)

Expand Down Expand Up @@ -62,10 +63,11 @@ func main() {
}

tokenSource := oauth2.StaticTokenSource(c.Token())
client := oauth2.NewClient(context.Background(), tokenSource)
httpClient := oauth2.NewClient(context.Background(), tokenSource)

checker := &Checker{
logger: logger,
client: githubql.NewClient(client),
client: githubv4.NewClient(httpClient),
}

// TODO: releases := make(chan Repository, len(c.Repositories))
Expand Down
33 changes: 17 additions & 16 deletions releasechecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import (
"strings"
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
githubql "github.com/shurcooL/githubql"
"github.com/go-kit/log"
"github.com/go-kit/log/level"

"github.com/shurcooL/githubv4"
)

// Checker has a githubql client to run queries and also knows about
// the current repositories releases to compare against.
type Checker struct {
logger log.Logger
client *githubql.Client
client *githubv4.Client
releases map[string]Repository
}

Expand Down Expand Up @@ -74,28 +75,28 @@ func (c *Checker) Run(interval time.Duration, repositories []string, releases ch
func (c *Checker) query(owner, name string) (Repository, error) {
var query struct {
Repository struct {
ID githubql.ID
Name githubql.String
Description githubql.String
URL githubql.URI
ID githubv4.ID
Name githubv4.String
Description githubv4.String
URL githubv4.URI

Releases struct {
Edges []struct {
Node struct {
ID githubql.ID
Name githubql.String
Description githubql.String
URL githubql.URI
PublishedAt githubql.DateTime
ID githubv4.ID
Name githubv4.String
Description githubv4.String
URL githubv4.URI
PublishedAt githubv4.DateTime
}
}
} `graphql:"releases(last: 1)"`
} `graphql:"releases(last: 1, orderBy: { field: CREATED_AT, direction: ASC})"`
} `graphql:"repository(owner: $owner, name: $name)"`
}

variables := map[string]interface{}{
"owner": githubql.String(owner),
"name": githubql.String(name),
"owner": githubv4.String(owner),
"name": githubv4.String(name),
}

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
Expand Down
13 changes: 0 additions & 13 deletions vendor/github.com/alexflint/go-arg/.travis.yml

This file was deleted.

105 changes: 92 additions & 13 deletions vendor/github.com/alexflint/go-arg/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions vendor/github.com/alexflint/go-arg/go.mod

This file was deleted.

8 changes: 0 additions & 8 deletions vendor/github.com/alexflint/go-arg/go.sum

This file was deleted.

Loading