Skip to content

Commit 20b1e1a

Browse files
authored
Support GITHUB_TOKEN (#79)
1 parent 7581b70 commit 20b1e1a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,5 @@ jobs:
2424
go-version: '1.21'
2525

2626
- name: 'Run tests'
27-
env:
28-
ACTIONS_TOKEN: '${{ github.token }}'
2927
run: |-
3028
go test -count=1 -shuffle=on -timeout=10m -race ./...

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function ratchet {
213213
system auth, similar to the Docker and gcloud CLIs.
214214

215215
- The GitHub resolver defaults to public github.com. Provide an oauth access
216-
token with appropriate permissions via the `ACTIONS_TOKEN` environment
216+
token with appropriate permissions via the `GITHUB_TOKEN` environment
217217
variable. To use a GitHub Enterprise installation, set the
218218
`ACTIONS_BASE_URL` and `ACTIONS_UPLOAD_URL` environment variables to point
219219
your instance.

resolver/actions.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
var (
1616
ActionsBaseURL = os.Getenv("ACTIONS_BASE_URL")
17-
ActionsToken = os.Getenv("ACTIONS_TOKEN")
17+
ActionsToken = coalesce(os.Getenv("ACTIONS_TOKEN"), os.Getenv("GITHUB_TOKEN"))
1818
ActionsUploadURL = os.Getenv("ACTIONS_UPLOAD_URL")
1919
)
2020

@@ -153,3 +153,12 @@ type GitHubRef struct {
153153
path string
154154
ref string
155155
}
156+
157+
func coalesce(s ...string) string {
158+
for _, v := range s {
159+
if v != "" {
160+
return v
161+
}
162+
}
163+
return ""
164+
}

0 commit comments

Comments
 (0)