Skip to content

Commit d472ef6

Browse files
authored
Merge pull request #552 from dscho/github-token
Work around API rate limits
2 parents 6e5bb47 + 7692a04 commit d472ef6

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ inputs:
3333
required: false
3434
description: 'Use @actions/cache to accelerate this Action'
3535
default: 'auto'
36+
github-token:
37+
description: >
38+
Personal access token (PAT) used to call into GitHub's REST API.
39+
We recommend using a service account with the least permissions necessary.
40+
Also when generating a new PAT, select the least scopes necessary.
41+
[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
42+
default: ${{ github.token }}
3643
runs:
3744
using: 'node16'
3845
main: 'dist/index.js'

dist/index.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ async function run(): Promise<void> {
7979

8080
const architectureToDownload =
8181
architecture === 'aarch64' ? 'x86_64' : architecture
82+
const githubToken = core.getInput('github-token')
8283
const verbose = core.getInput('verbose')
8384
const msysMode = core.getInput('msys') === 'true'
8485

8586
const {artifactName, download, id} = await getViaGit(
8687
flavor,
87-
architectureToDownload
88+
architectureToDownload,
89+
githubToken
8890
)
8991
const outputDirectory = core.getInput('path') || `C:/${artifactName}`
9092
let useCache: boolean

src/git.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ async function clone(
7474

7575
export async function getViaGit(
7676
flavor: string,
77-
architecture: string
77+
architecture: string,
78+
githubToken?: string
7879
): Promise<{
7980
artifactName: string
8081
id: string
@@ -90,7 +91,7 @@ export async function getViaGit(
9091
architecture
9192
)
9293

93-
const octokit = new Octokit()
94+
const octokit = githubToken ? new Octokit({auth: githubToken}) : new Octokit()
9495
let head_sha: string
9596
if (flavor === 'minimal') {
9697
const info = await octokit.actions.listWorkflowRuns({

0 commit comments

Comments
 (0)