Skip to content

Commit

Permalink
Merge pull request #125 from cyberhck/patch-1
Browse files Browse the repository at this point in the history
feat: allow zip files to be downloaded
  • Loading branch information
ksivamuthu authored May 25, 2024
2 parents 52a7c66 + 724286b commit 62ed3a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
version:
required: false
description: 'gh cli version to download'
archive_format:
required: false
description: 'the format of the archive that is published at: github.com/cli/cli/releases (defaults to .tar.gz)'
runs:
using: 'node16'
main: 'dist/index.js'
7 changes: 4 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@actions/core'
import * as os from 'os'

import {cacheFile, downloadTool, extractTar, find} from '@actions/tool-cache'
import {cacheFile, downloadTool, extractTar, find, extractZip} from '@actions/tool-cache'
import {chmodSync} from 'fs'
import {HttpClient} from '@actions/http-client'

Expand All @@ -26,7 +26,8 @@ async function install(): Promise<void> {
const version = core.getInput('version') || (await getLatestVersion())

const platform = core.getInput('platform') || os.platform()
const packageUrl = `https://github.com/cli/cli/releases/download/v${version}/gh_${version}_${platform}_amd64.tar.gz`
const archive_format = core.getInput('archive_format') || 'tar.gz'
const packageUrl = `https://github.com/cli/cli/releases/download/v${version}/gh_${version}_${platform}_amd64.${archive_format}`

core.info(`Downloading gh cli from ${packageUrl}`)

Expand All @@ -35,7 +36,7 @@ async function install(): Promise<void> {
if (!cliPath) {
const downloadPath = await downloadTool(packageUrl, 'gh_tar')
chmodSync(downloadPath, '755')
cliPath = await extractTar(downloadPath, find(GH_CLI_TOOL_NAME, version))
cliPath = archive_format === 'tar.gz' ? await extractTar(downloadPath, find(GH_CLI_TOOL_NAME, version)) : await extractZip(downloadPath, find(GH_CLI_TOOL_NAME, version))
cliPath = await cacheFile(
`${cliPath}/gh_${version}_${platform}_amd64/bin/gh`,
'gh',
Expand Down

0 comments on commit 62ed3a6

Please sign in to comment.