diff --git a/README.md b/README.md index 15f2b5d..30e559e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ``` diff --git a/action.yml b/action.yml index 4d32a83..5ab6db3 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/src/run.js b/src/run.js index 4f8b943..10aa1c7 100644 --- a/src/run.js +++ b/src/run.js @@ -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 { @@ -38,5 +40,4 @@ async function downloadGhCli(version) { throw err; } } - run();