Skip to content

Commit 0700ca1

Browse files
committed
Add the tool's bin to path
1 parent 3ced26d commit 0700ca1

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

dist/index.js

Lines changed: 10 additions & 3 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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const path = require('path');
12
const core = require('@actions/core');
23
const tc = require('@actions/tool-cache');
34
const { getDownloadURL } = require('./lib/utils');
@@ -7,13 +8,14 @@ async function setup() {
78
const version = core.getInput('version');
89

910
// Download the specific version of the tool, e.g. as a tarball
10-
const pathToTarball = await tc.downloadTool(getDownloadURL(version));
11+
const downloadURL = getDownloadURL(version);
12+
const pathToTarball = await tc.downloadTool(downloadURL.url);
1113

1214
// Extract the tarball onto host runner
1315
const pathToCLI = await tc.extractTar(pathToTarball);
1416

1517
// Expose the tool by adding it to the PATH
16-
core.addPath(pathToCLI)
18+
core.addPath(path.join(pathToCLI, downloadURL.filename, 'bin'));
1719
}
1820

1921
module.exports = setup

lib/utils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ function mapOS(os) {
2121
}
2222

2323
function getDownloadURL(version) {
24-
return `https://github.com/cli/cli/releases/download/v${ version }/gh_${ version }_${ mapOS(os.platform()) }_${ mapArch(os.arch()) }.tar.gz`
24+
const filename = `gh_${ version }_${ mapOS(os.platform()) }_${ mapArch(os.arch()) }`;
25+
const url = `https://github.com/cli/cli/releases/download/v${ version }/${ filename }.tar.gz`;
26+
return {
27+
url,
28+
filename
29+
};
2530
}
2631

2732
module.exports = { getDownloadURL }

0 commit comments

Comments
 (0)