Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Selfhosted runners do not come with the GH CLI out of the box. This action is an easy-to-use way to install it.

As of now, only linux amd64 is supported.
Supports arm64, amd64 and 386 architectures

## Usage

Expand All @@ -11,4 +11,5 @@ As of now, only linux amd64 is supported.
uses: dev-hanz-ops/install-gh-cli-action@v0.2.0
with:
gh-cli-version: 2.32.0 # optional, see action.yml for current default
gh-cli-architcture: amd64 # optional, see action.yml for current default
```
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ inputs:
description: 'Version of the GitHub-CLI that should be installed'
required: false
default: '2.14.2'
gh-cli-arch:
description: 'Target architecture: amd64, arm64, 386'
default: amd64
runs:
using: 'node20'
main: 'dist/index.js'
17 changes: 9 additions & 8 deletions src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@ import * as path from 'path';
async function run() {
try {
let version = core.getInput('gh-cli-version');
if (version) {
await getGhCli(version);
let architecture = core.getInput('gh-cli-arch');
console.log(`Hello ${architecture}!`);
if (version && architecture) {
await getGhCli(version,architecture);
}
} catch (error) {
core.setFailed(error.message);
}
}

async function getGhCli(version) {
async function getGhCli(version,architecture) {
let toolPath = tc.find('gh-cli', version);

if (!toolPath) {
toolPath = await downloadGhCli(version);
toolPath = await downloadGhCli(version,architecture);
}

toolPath = path.join(toolPath, 'bin');
core.addPath(toolPath);
}

async function downloadGhCli(version) {
const toolDirectoryName = `gh_${version}_linux_amd64`;
const downloadUrl = `https://github.com/cli/cli/releases/download/v${version}/gh_${version}_linux_amd64.tar.gz`;
async function downloadGhCli(version,architecture) {
const toolDirectoryName = `gh_${version}_linux_${architecture}`;
const downloadUrl = `https://github.com/cli/cli/releases/download/v${version}/gh_${version}_linux_${architecture}.tar.gz`;
console.log(`downloading ${downloadUrl}`);

try {
Expand All @@ -38,5 +40,4 @@ async function downloadGhCli(version) {
throw err;
}
}

run();