-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use own command for github cli install to allow for
when
use (#…
…48)
- Loading branch information
1 parent
191b6fa
commit 89f4dad
Showing
5 changed files
with
83 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,3 @@ description: > | |
display: | ||
source_url: "https://github.com/ankorstore/orb-toolbelt" | ||
|
||
orbs: | ||
github-cli: circleci/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
description: >- | ||
Install the gh cli without authenticating or configuring. This command should | ||
be run before invoking the gh cli. | ||
parameters: | ||
version: | ||
default: 2.3.0 | ||
description: Specify the full semver versioned tag to use. | ||
type: string | ||
when: | ||
default: on_success | ||
description: When to run this command. | ||
enum: | ||
- always | ||
- on_success | ||
- on_fail | ||
type: enum | ||
steps: | ||
- run: | ||
when: << parameters.when >> | ||
command: << include(scripts/install_github_cli.sh) >> | ||
environment: | ||
PARAM_GH_CLI_VERSION: <<parameters.version>> | ||
name: Install GH CLI v<<parameters.version>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
# set smart sudo | ||
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi | ||
|
||
# Define current platform | ||
if [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "x86_64" ]]; then | ||
export SYS_ENV_PLATFORM=macos | ||
elif [[ "$(uname -s)" == "Linux" && "$(uname -m)" == "x86_64" ]]; then | ||
export SYS_ENV_PLATFORM=linux_x86 | ||
elif [[ "$(uname -s)" == "Linux" && "$(uname -m)" == "aarch64" ]]; then | ||
export SYS_ENV_PLATFORM=linux_arm | ||
else | ||
echo "This platform appears to be unsupported." | ||
uname -a | ||
exit 1 | ||
fi | ||
|
||
# If not installed | ||
if ! command -v gh >/dev/null 2>&1; then | ||
echo "Installing the GitHub CLI" | ||
case $SYS_ENV_PLATFORM in | ||
linux_x86) | ||
curl -sSL "https://github.com/cli/cli/releases/download/v${PARAM_GH_CLI_VERSION}/gh_${PARAM_GH_CLI_VERSION}_linux_amd64.deb" -o "gh-cli.deb" | ||
$SUDO apt install ./gh-cli.deb | ||
rm gh-cli.deb | ||
;; | ||
macos) | ||
curl -sSL "https://github.com/cli/cli/releases/download/v${PARAM_GH_CLI_VERSION}/gh_${PARAM_GH_CLI_VERSION}_macOS_amd64.tar.gz" -o "gh-cli.tar.gz" | ||
$SUDO tar -xf ./gh-cli.tar.gz -C /usr/local/ --strip-components=1 | ||
rm gh-cli.tar.gz | ||
;; | ||
linux_arm) | ||
curl -sSL "https://github.com/cli/cli/releases/download/v${PARAM_GH_CLI_VERSION}/gh_${PARAM_GH_CLI_VERSION}_linux_arm64.tar.gz" -o "gh-cli.tar.gz" | ||
$SUDO tar -xf ./gh-cli.tar.gz -C /usr/local/ --strip-components=1 | ||
rm gh-cli.tar.gz | ||
;; | ||
*) | ||
echo "This orb does not currently support your platform." | ||
exit 1 | ||
;; | ||
esac | ||
# Validate install. | ||
echo | ||
echo "GH CLI installed" | ||
command -v gh | ||
else | ||
echo "GH CLI is already installed." | ||
fi |