diff --git a/config.example.yml b/config.example.yml index 72f56b9..d89aeeb 100644 --- a/config.example.yml +++ b/config.example.yml @@ -1,5 +1,6 @@ owner: ATOR-Development repo: ator-protocol +token: "" cachePeriod: 1m artifacts: - name: macos-amd64 diff --git a/internal/config/config.go b/internal/config/config.go index 671ac15..12f5e46 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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"` } diff --git a/internal/downloads/downloads.go b/internal/downloads/downloads.go index 2aca699..82a489a 100644 --- a/internal/downloads/downloads.go +++ b/internal/downloads/downloads.go @@ -24,6 +24,7 @@ type Artifact struct { type Downloads struct { owner string repo string + token string releases []*release cachePeriod time.Duration @@ -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, @@ -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)