Skip to content

Commit

Permalink
Use github api token
Browse files Browse the repository at this point in the history
  • Loading branch information
floodcode committed Mar 27, 2024
1 parent 0c9bcd2 commit 6c9ecdd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.example.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
owner: ATOR-Development
repo: ator-protocol
token: ""
cachePeriod: 1m
artifacts:
- name: macos-amd64
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
type Config struct {
Owner string `yaml:"owner"`
Repo string `yaml:"repo"`
Token string `yaml:"token"`
CachePeriod string `yaml:"cachePeriod"`
Artifacts []Artifact `yaml:"artifacts"`
}
Expand Down
6 changes: 6 additions & 0 deletions internal/downloads/downloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Artifact struct {
type Downloads struct {
owner string
repo string
token string
releases []*release
cachePeriod time.Duration

Expand Down Expand Up @@ -56,6 +57,7 @@ func New(cfg *config.Config, logger log.Logger) (*Downloads, error) {
return &Downloads{
owner: cfg.Owner,
repo: cfg.Repo,
token: cfg.Token,
releases: releases,
cachePeriod: cachePeriod,

Expand Down Expand Up @@ -99,6 +101,10 @@ func (d *Downloads) fetchArtifacts(ctx context.Context) ([]*Artifact, error) {
return nil, err
}

req.Header.Add("Accept", "application/vnd.github+json")
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", d.token))
req.Header.Add("X-GitHub-Api-Version", "2022-11-28")

req = req.WithContext(ctx)

resp, err := http.DefaultClient.Do(req)
Expand Down

0 comments on commit 6c9ecdd

Please sign in to comment.