Add API token header to prevent side effects during tests (#16)

* feat: add API token header to prevent side effects during tests

Signed-off-by: Dmitry Kisler <admin@dkisler.com>
This commit is contained in:
Dmitry Kisler 2023-10-26 22:29:12 +02:00 committed by GitHub
parent 5f01fa71eb
commit 6cdd07fc43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 9 deletions

View file

@ -10,6 +10,9 @@ defaults:
run:
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
tofu-versions:
name: 'OpenTofu Versions'
@ -181,4 +184,3 @@ jobs:
if: runner.os != 'Windows'
run: |
[[ -f ${HOME}/.tofurc ]] || exit 0

14
dist/index.js vendored
View file

@ -36,11 +36,17 @@ class Release {
async function fetchReleases () {
const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
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}`;
}
const resp = await fetch(url, {
headers: {
Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28'
}
headers
});
if (!resp.ok) {

View file

@ -30,11 +30,17 @@ class Release {
async function fetchReleases () {
const url = 'https://api.github.com/repos/opentofu/opentofu/releases';
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}`;
}
const resp = await fetch(url, {
headers: {
Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28'
}
headers
});
if (!resp.ok) {