diff --git a/action.yml b/action.yml index daadfd8..92bb6be 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,10 @@ inputs: description: 'Whether or not to install a wrapper to wrap subsequent calls of the `tofu` binary and expose its STDOUT, STDERR, and exit code as outputs named `stdout`, `stderr`, and `exitcode` respectively. Defaults to `true`.' default: 'true' required: false + github-token: + description: The GitHub token used to requests GitHub API + default: ${{ github.token }} + required: false outputs: stdout: description: 'The STDOUT stream of the call to the `tofu` binary.' diff --git a/dist/index.js b/dist/index.js index 6c2709a..044c552 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9,6 +9,9 @@ * SPDX-License-Identifier: MPL-2.0 */ +// External +const core = __nccwpck_require__(2186); + class Build { constructor (name, url) { this.name = name; @@ -35,14 +38,15 @@ class Release { */ async function fetchReleases () { const url = 'https://api.github.com/repos/opentofu/opentofu/releases'; + const githubToken = core.getInput('github_token'); const headers = { Accept: 'application/vnd.github+json', 'X-GitHub-Api-Version': '2022-11-28' }; - if (process.env.GITHUB_TOKEN) { - headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`; + if (githubToken) { + headers.Authorization = `Bearer ${githubToken}`; } const resp = await fetch(url, { diff --git a/lib/releases.js b/lib/releases.js index 0947a53..bd59186 100644 --- a/lib/releases.js +++ b/lib/releases.js @@ -3,6 +3,9 @@ * SPDX-License-Identifier: MPL-2.0 */ +// External +const core = require('@actions/core'); + class Build { constructor (name, url) { this.name = name; @@ -29,14 +32,15 @@ class Release { */ async function fetchReleases () { const url = 'https://api.github.com/repos/opentofu/opentofu/releases'; + const githubToken = core.getInput('github_token'); const headers = { Accept: 'application/vnd.github+json', 'X-GitHub-Api-Version': '2022-11-28' }; - if (process.env.GITHUB_TOKEN) { - headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`; + if (githubToken) { + headers.Authorization = `Bearer ${githubToken}`; } const resp = await fetch(url, {