diff --git a/.github/workflows/setup-tofu.yml b/.github/workflows/setup-tofu.yml index af2d381..6582a61 100644 --- a/.github/workflows/setup-tofu.yml +++ b/.github/workflows/setup-tofu.yml @@ -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 - diff --git a/dist/index.js b/dist/index.js index 651b12e..6c2709a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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) { diff --git a/lib/releases.js b/lib/releases.js index 295d09e..0947a53 100644 --- a/lib/releases.js +++ b/lib/releases.js @@ -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) {