Skip to content

Commit

Permalink
Support GITHUB_TOKEN (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo authored Apr 17, 2024
1 parent 7581b70 commit 20b1e1a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ jobs:
go-version: '1.21'

- name: 'Run tests'
env:
ACTIONS_TOKEN: '${{ github.token }}'
run: |-
go test -count=1 -shuffle=on -timeout=10m -race ./...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function ratchet {
system auth, similar to the Docker and gcloud CLIs.

- The GitHub resolver defaults to public github.com. Provide an oauth access
token with appropriate permissions via the `ACTIONS_TOKEN` environment
token with appropriate permissions via the `GITHUB_TOKEN` environment
variable. To use a GitHub Enterprise installation, set the
`ACTIONS_BASE_URL` and `ACTIONS_UPLOAD_URL` environment variables to point
your instance.
Expand Down
11 changes: 10 additions & 1 deletion resolver/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

var (
ActionsBaseURL = os.Getenv("ACTIONS_BASE_URL")
ActionsToken = os.Getenv("ACTIONS_TOKEN")
ActionsToken = coalesce(os.Getenv("ACTIONS_TOKEN"), os.Getenv("GITHUB_TOKEN"))
ActionsUploadURL = os.Getenv("ACTIONS_UPLOAD_URL")
)

Expand Down Expand Up @@ -153,3 +153,12 @@ type GitHubRef struct {
path string
ref string
}

func coalesce(s ...string) string {
for _, v := range s {
if v != "" {
return v
}
}
return ""
}

0 comments on commit 20b1e1a

Please sign in to comment.