mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2025-12-31 15:02:19 +00:00
feat: add API token header to prevent side effects during tests
Signed-off-by: Dmitry Kisler <admin@dkisler.com>
This commit is contained in:
parent
8767493626
commit
1d73e2cfc3
3 changed files with 23 additions and 9 deletions
4
.github/workflows/setup-tofu.yml
vendored
4
.github/workflows/setup-tofu.yml
vendored
|
|
@ -10,6 +10,9 @@ defaults:
|
||||||
run:
|
run:
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secret.GITHUB_TOKEN }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tofu-versions:
|
tofu-versions:
|
||||||
name: 'OpenTofu Versions'
|
name: 'OpenTofu Versions'
|
||||||
|
|
@ -181,4 +184,3 @@ jobs:
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
run: |
|
run: |
|
||||||
[[ -f ${HOME}/.tofurc ]] || exit 0
|
[[ -f ${HOME}/.tofurc ]] || exit 0
|
||||||
|
|
||||||
|
|
|
||||||
14
dist/index.js
vendored
14
dist/index.js
vendored
|
|
@ -36,11 +36,17 @@ 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 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, {
|
const resp = await fetch(url, {
|
||||||
headers: {
|
headers
|
||||||
Accept: 'application/vnd.github+json',
|
|
||||||
'X-GitHub-Api-Version': '2022-11-28'
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,17 @@ 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 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, {
|
const resp = await fetch(url, {
|
||||||
headers: {
|
headers
|
||||||
Accept: 'application/vnd.github+json',
|
|
||||||
'X-GitHub-Api-Version': '2022-11-28'
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!resp.ok) {
|
if (!resp.ok) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue