feat: move GITHUB_TOKEN to inputs

Signed-off-by: Nicolas Brousse <n.brousse@pantographe.studio>
This commit is contained in:
Nicolas Brousse 2024-01-19 01:15:22 +00:00 committed by Nicolas Brousse
parent 05c2a037e9
commit b7e297d052
No known key found for this signature in database
GPG key ID: F65D59468E63D5A9
3 changed files with 16 additions and 4 deletions

View file

@ -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.'

8
dist/index.js vendored
View file

@ -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, {

View file

@ -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, {