Skip to content

Commit 6532988

Browse files
authored
Merge pull request #59 from roots/set-auth-token
Set auth token when available
2 parents 04972b7 + aeb1f66 commit 6532988

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

dist/index.js

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ async function getRelease(version) {
3131
core.debug(`Finding release for ${version} (${osPlatform}_${osArch})`);
3232
const release = await fetchRelease(version);
3333

34-
if (!release) {
34+
if (!release.name) {
35+
core.info(`API response: ${release}`);
3536
throw new Error(`No trellis-cli release found for version ${version}`);
3637
}
3738

@@ -55,6 +56,12 @@ async function getRelease(version) {
5556

5657
async function fetchRelease(version) {
5758
const client = new http.HttpClient('setup-trellis-cli-client');
59+
60+
let headers = {};
61+
if (process.env.GITHUB_TOKEN) {
62+
headers['authorization'] = `Bearer ${process.env.GITHUB_TOKEN}`;
63+
}
64+
5865
let url = null;
5966

6067
if (version === 'latest' || version === '') {
@@ -63,7 +70,7 @@ async function fetchRelease(version) {
6370
url = `https://api.github.com/repos/roots/trellis-cli/releases/tags/${version}`;
6471
}
6572

66-
const response = await client.get(url);
73+
const response = await client.get(url, headers);
6774
const body = await response.readBody();
6875
return JSON.parse(body);
6976
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"homepage": "https://github.com/roots/setup-trellis-cli",
2929
"dependencies": {
3030
"@actions/cache": "^3.0.5",
31-
"@actions/core": "^1.6.0",
31+
"@actions/core": "^1.10.0",
3232
"@actions/exec": "^1.1.1",
3333
"@actions/glob": "^0.2.0",
3434
"@actions/http-client": "^1.0.11",

0 commit comments

Comments
 (0)