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
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,24 @@ jobs:
ibmcloud target | grep -q '^Region:\s\+us-south$' &&
ibmcloud target | grep -q '^Resource group:\s\+default$'

test-already-installed:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- name: Set up ibmcloud CLI
uses: ./
- name: Set up ibmcloud CLI (again)
uses: ./
- name: Check basic CLI function
run: ibmcloud --version

test-multiple-platforms:
strategy:
matrix:
Expand Down
26 changes: 16 additions & 10 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
"package": "ncc build src/index.js -o dist --source-map --license licenses.txt"
},
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1"
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3"
},
"devDependencies": {
"@vercel/ncc": "^0.38.1"
Expand Down
26 changes: 16 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const core = require('@actions/core')
const exec = require('@actions/exec')
const io = require('@actions/io')

/**
* Colorize a string with ANSI codes.
Expand All @@ -14,16 +15,21 @@ function colorize(string, color) {

async function installCLI() {
core.startGroup('Installing IBM Cloud CLI')
if (process.platform == 'win32') {
await exec.exec(`powershell -command "iex (New-Object Net.WebClient).DownloadString('https://clis.cloud.ibm.com/install/powershell')"`)
// Add to PATH for the current step
process.env.PATH += ';C:\\Program Files\\IBM\\Cloud\\bin'
// Add to GITHUB_PATH for future steps
await exec.exec(`powershell -command "Add-Content $env:GITHUB_PATH 'C:\\Program Files\\IBM\\Cloud\\bin'"`)
} else if (process.platform == 'darwin') {
await exec.exec('/bin/bash -c "curl -fsSL https://clis.cloud.ibm.com/install/osx | sh"')
const cliPath = await io.which("ibmcloud")
if (cliPath) {
core.info("IBM Cloud CLI is already installed.")
} else {
await exec.exec('/bin/bash -c "curl -fsSL https://clis.cloud.ibm.com/install/linux | sh"')
if (process.platform == 'win32') {
await exec.exec(`powershell -command "iex (New-Object Net.WebClient).DownloadString('https://clis.cloud.ibm.com/install/powershell')"`)
// Add to PATH for the current step
process.env.PATH += ';C:\\Program Files\\IBM\\Cloud\\bin'
// Add to GITHUB_PATH for future steps
await exec.exec(`powershell -command "Add-Content $env:GITHUB_PATH 'C:\\Program Files\\IBM\\Cloud\\bin'"`)
} else if (process.platform == 'darwin') {
await exec.exec('/bin/bash -c "curl -fsSL https://clis.cloud.ibm.com/install/osx | sh"')
} else {
await exec.exec('/bin/bash -c "curl -fsSL https://clis.cloud.ibm.com/install/linux | sh"')
}
}
core.endGroup()
}
Expand Down Expand Up @@ -101,8 +107,8 @@ async function login() {
async function run() {
try {
await installCLI()
await disableVersionChecking()
await captureVersion()
await disableVersionChecking()
await installPlugins()
await setApiEndpoint()
await login()
Expand Down
Loading