feat: use GITHUB_TOKEN when not 3rd party runner and github-token input empty

Signed-off-by: Nicolas Brousse <n.brousse@pantographe.studio>
This commit is contained in:
Nicolas Brousse 2024-01-30 14:04:39 +01:00
parent db353172f3
commit aee8f86b30
No known key found for this signature in database
GPG key ID: F65D59468E63D5A9
2 changed files with 4 additions and 2 deletions

3
dist/index.js vendored
View file

@ -39,13 +39,14 @@ class Release {
async function fetchReleases () { async function fetchReleases () {
const url = 'https://api.github.com/repos/opentofu/opentofu/releases'; const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
const githubToken = core.getInput('github_token'); const githubToken = core.getInput('github_token');
const is3rdPartyRunner = process.env.FORGEJO_ACTIONS || process.env.GITEA_ACTIONS;
const headers = { const headers = {
Accept: 'application/vnd.github+json', Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28' 'X-GitHub-Api-Version': '2022-11-28'
}; };
if (githubToken) { if (githubToken === '' && !is3rdPartyRunner) {
headers.Authorization = `Bearer ${githubToken}`; headers.Authorization = `Bearer ${githubToken}`;
} }

View file

@ -33,13 +33,14 @@ class Release {
async function fetchReleases () { async function fetchReleases () {
const url = 'https://api.github.com/repos/opentofu/opentofu/releases'; const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
const githubToken = core.getInput('github_token'); const githubToken = core.getInput('github_token');
const is3rdPartyRunner = process.env.FORGEJO_ACTIONS || process.env.GITEA_ACTIONS;
const headers = { const headers = {
Accept: 'application/vnd.github+json', Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28' 'X-GitHub-Api-Version': '2022-11-28'
}; };
if (githubToken) { if (githubToken === '' && !is3rdPartyRunner) {
headers.Authorization = `Bearer ${githubToken}`; headers.Authorization = `Bearer ${githubToken}`;
} }