mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2025-12-31 15:02:19 +00:00
feat: move GITHUB_TOKEN to inputs
Signed-off-by: Nicolas Brousse <n.brousse@pantographe.studio>
This commit is contained in:
parent
05c2a037e9
commit
b7e297d052
3 changed files with 16 additions and 4 deletions
|
|
@ -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
8
dist/index.js
vendored
|
|
@ -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, {
|
||||
|
|
|
|||
|
|
@ -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, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue