Skip to content

Commit 8a22b94

Browse files
committed
fix: ensure raw_output is a string
Signed-off-by: Avi Miller <[email protected]>
1 parent 88f7996 commit 8a22b94

File tree

7 files changed

+64
-56
lines changed

7 files changed

+64
-56
lines changed

.github/workflows/sanity-test.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ jobs:
2323
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
2424

2525
steps:
26-
- name: Checkout
27-
id: checkout
28-
uses: actions/checkout@v4
26+
- uses: actions/checkout@v4
2927

3028
- name: Get object storage namespace
3129
id: test-action-get-os-ns
3230
uses: ./
3331
with:
34-
command: os ns get
32+
command: 'iam compartment list --compartment-id-in-subtree=true'
33+
query: "data[?name=='github-actions'].id"
34+
silent: false
3535

36-
- name: Output object storage namespace
37-
id: output-os-ns
38-
run: echo "${{ steps.test-action-get-os-ns.outputs.output }}"
36+
- name: Echo object storage namespace
37+
id: echo-os-ns-get
38+
run: |
39+
echo "Output: ${{ steps.test-action-get-os-ns.outputs.output}}"
40+
echo "Raw output: ${{ steps.test-action-get-os-ns.outputs.raw_output}}"
3941
4042
- name: Test non-JSON output
4143
id: test-non-json-output

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ jobs:
6565
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
6666
steps:
6767
- name: Retrieve the OCID of a named compartment in tenancy
68-
uses: oracle-actions/[email protected].0
68+
uses: oracle-actions/[email protected].1
6969
id: find-compartment-id
7070
with:
7171
command: 'iam compartment list --compartment-id-in-subtree=true'
7272
query: "data[?name=='testing'].id"
7373

7474
- name: Retrieve the display name and shape of the instances in my compartment
75-
uses: oracle-actions/[email protected].0
75+
uses: oracle-actions/[email protected].1
7676
id: find-instances
7777
with:
7878
command: 'compute instance list --compartment-id ${{ steps.find-compartment-id.outputs.raw_output }}'

dist/index.js

+21-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+21-18
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,29 @@
11
{
22
"name": "@oracle-actions/run-oci-cli-command",
3-
"version": "1.3.0",
3+
"description": "Run an Oracle Cloud Infrastructure (OCI) CLI command",
4+
"version": "1.3.1",
45
"author": {
56
"name": "Oracle Cloud Infrastructure",
67
"email": "[email protected]"
78
},
8-
"description": "Run an Oracle Cloud Infrastructure (OCI) CLI command",
9-
"main": "src/main.ts",
9+
"private": true,
10+
"homepage": "https://github.com/oracle-actions/run-oci-cli-command#readme",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/oracle-actions/run-oci-cli-command.git"
14+
},
15+
"bugs": {
16+
"url": "https://github.com/oracle-actions/run-oci-cli-command/issues"
17+
},
18+
"keywords": [
19+
"github",
20+
"actions",
21+
"oracle-cloud",
22+
"oracle-cloud-infrastructure"
23+
],
24+
"exports": {
25+
".": "./dist/index.js"
26+
},
1027
"engines": {
1128
"node": ">=20"
1229
},
@@ -15,29 +32,15 @@
1532
"format:write": "npx prettier --write .",
1633
"format:check": "npx prettier --check .",
1734
"lint": "npx eslint . -c ./.github/linters/.eslintrc.yml",
18-
"package": "npx ncc build src/main.ts -o dist --source-map --license LICENSE.txt",
35+
"package": "npx ncc build src/index.ts -o dist --source-map --license LICENSE.txt",
1936
"all": "npm run format:write && npm run lint && npm run package"
2037
},
21-
"repository": {
22-
"type": "git",
23-
"url": "git+https://github.com/oracle-actions/run-oci-cli-command.git"
24-
},
2538
"files": [
2639
"LICENSE.txt",
2740
"THIRD_PARTY_LICENSES.txt",
2841
"dist/*"
2942
],
30-
"keywords": [
31-
"github",
32-
"actions",
33-
"oracle-cloud",
34-
"oracle-cloud-infrastructure"
35-
],
3643
"license": "UPL-1.0",
37-
"bugs": {
38-
"url": "https://github.com/oracle-actions/run-oci-cli-command/issues"
39-
},
40-
"homepage": "https://github.com/oracle-actions/run-oci-cli-command#readme",
4144
"dependencies": {
4245
"@actions/core": "^1.10.1",
4346
"@actions/exec": "^1.1.1",

src/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* Copyright (c) 2024, Oracle and/or its affiliates.
2+
* Licensed under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
*/
4+
import { runOciCliCommand } from './main'
5+
6+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
7+
runOciCliCommand()

src/main.ts

+3-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function isJson(item: string): boolean {
3232
* data.
3333
*
3434
*/
35-
async function runOciCliCommand(): Promise<void> {
35+
export async function runOciCliCommand(): Promise<void> {
3636
if (!fs.existsSync(path.join(os.homedir(), '.oci-cli-installed'))) {
3737
core.startGroup('Installing Oracle Cloud Infrastructure CLI')
3838
const cli = await exec.getExecOutput('python -m pip install oci-cli')
@@ -56,7 +56,6 @@ async function runOciCliCommand(): Promise<void> {
5656
if (silent) core.setSecret(cliCommand)
5757

5858
const cliResult = await exec.getExecOutput(cliCommand, [], { silent: silent })
59-
let stdout = {}
6059
let output = ''
6160
let raw_output = ''
6261

@@ -65,10 +64,10 @@ async function runOciCliCommand(): Promise<void> {
6564
output = cliResult.stdout
6665
raw_output = cliResult.stdout
6766
} else {
68-
stdout = JSON.parse(cliResult.stdout)
67+
const stdout = JSON.parse(cliResult.stdout)
6968
output = JSON.stringify(JSON.stringify(stdout))
7069
if (Object.keys(stdout).length == 1) {
71-
raw_output = Object.keys(stdout)[0]
70+
raw_output = String(Object.values(stdout)[0])
7271
}
7372
}
7473

@@ -82,10 +81,3 @@ async function runOciCliCommand(): Promise<void> {
8281
core.setFailed(`Failed: ${JSON.stringify(stderr)}`)
8382
}
8483
}
85-
86-
/**
87-
* Requires OCI CLI environment variables to be set
88-
*/
89-
runOciCliCommand().catch(e => {
90-
if (e instanceof Error) core.setFailed(e.message)
91-
})

0 commit comments

Comments
 (0)