Skip to content

Commit 7490806

Browse files
committed
Update README.md with a better example of how to use this Action
Signed-off-by: Avi Miller <avi.miller@oracle.com>
1 parent e175c64 commit 7490806

File tree

1 file changed

+24
-31
lines changed

1 file changed

+24
-31
lines changed

README.md

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
11
# run-oci-cli-command v1.0
22

3-
This GitHub Action installs the OCI CLI and then runs the specified command.
4-
This action will automatically cache the OCI CLI install to speed up any
5-
subsequent steps that use this action.
3+
This GitHub Action installs the OCI CLI and then runs the specified command. This action will automatically cache the OCI CLI install to speed up any subsequent steps that use this action.
64

75
## Required environment variables
86

9-
The following [OCI CLI environment variables][1] must be defined for at least
10-
the `run-oci-cli-command` task:
7+
The following [OCI CLI environment variables][1] must be defined for at least the `run-oci-cli-command` task:
118

129
* `OCI_CLI_USER`
1310
* `OCI_CLI_TENANCY`
1411
* `OCI_CLI_FINGERPRINT`
1512
* `OCI_CLI_KEY_CONTENT`
1613
* `OCI_CLI_REGION`
1714

18-
We recommend using GitHub Secrets to store these values. If you have more than
19-
one `run-oci-cli-command` task, consider [defining your environment variables][2] at
20-
the job or workflow level.
15+
We recommend using GitHub Secrets to store these values. If you have more than one `run-oci-cli-command` task, consider [defining your environment variables][2] at the job or workflow level.
2116

2217
## Inputs
2318

2419
* `command` (required): the [command and arguments][3] to provide to the `oci` tool.
25-
* `query`: (optional) a [JMESPath query](http://jmespath.org/) to run on the
26-
response JSON before output.
20+
* `query`: (optional) a [JMESPath query][4] to run on the response JSON before output.
2721

2822
### Output masking
2923

30-
By default, the output(s) from the command are masked from the GitHub Actions log
31-
and GitHub console, to prevent leaking any credential or confidential information.
32-
The following option will disable that masking and is intended for debugging
33-
purposes only:
24+
By default, the output(s) from the command are masked from the GitHub Actions log and GitHub console, to prevent leaking any credential or confidential information. The following option will disable that masking and is intended for debugging purposes only:
3425

35-
* `silent`: (Optional; default: _true_) If set to _false_ the action will
36-
not mask or suppress the command or outputs from the logs or console.
26+
* `silent`: (Optional; default: _true_) If set to _false_ the action will not mask or suppress the command or outputs from the logs or console.
3727

38-
> **Note:** the output does not need to be visible in the log to be used as an
39-
> input by another task.
28+
> **Note:** the output does not need to be visible in the log to be used as an > input by another task.
4029
4130
## Outputs
4231

4332
* `output`: will contain the results of the command in JSON format.
44-
* `raw_output`: if the output of a given query is a single string value, this
45-
will return the string without surrounding quotes.
33+
* `raw_output`: if the output of a given query is a single string value, this will return the string without surrounding quotes.
4634

47-
> **Note:** filtering the `output` or `raw_output` by piping it through another
48-
> tool like `jq` may result in the filtered output being visible in the job
49-
> logs. _Using a JMESPath query to filter results is recommend instead_.
35+
> **Note:** filtering the `output` or `raw_output` by piping it through another tool like `jq` may result in the filtered output being visible in the job logs. We recommend using the `query` parameter instead.
5036
5137
## Sample workflow
5238

39+
The following example lists all compute instances found in the `testing` compartment of the `OCI_CLI_TENANCY` in the `OCI_CLI_REGION` region.
40+
41+
To change the name of the compartment, modifying the `query` parameter of the `find-compartment-id` step.
42+
43+
To change which fields are returned, modify the `query` parameter of the `find-instasnces` step.
44+
5345
```yaml
5446
jobs:
5547
my-instances:
@@ -63,25 +55,25 @@ jobs:
6355
OCI_CLI_REGION: ${{ secrets.OCI_CLI_REGION }}
6456
steps:
6557
- name: Retrieve the OCID of a named compartment in tenancy
66-
uses: oracle-actions/run-oci-cli-command@v1
67-
id: get-compartment-ocid
58+
uses: oracle-actions/run-oci-cli-command@v1.0
59+
id: find-compartment-id
6860
with:
69-
command: 'iam compartment list'
70-
jmespath: "data[?name=='my-compartment'].id"
61+
command: 'iam compartment list --compartment-id-in-subtree=true'
62+
query: "data[?name=='testing'].id"
7163

7264
- name: Retrieve the display name and shape of the instances in my compartment
7365
uses: oracle-actions/run-oci-cli-command@v1.0
74-
id: find-my-instances-instances
66+
id: find-instances
7567
with:
76-
command: 'compute instance list --compartment-id ${{ steps.compartment-ocid.get-compartment-ocid.raw_output }}'
77-
jmespath: 'data[*].{name: \"display-name\", shape: shape}'
68+
command: 'compute instance list --compartment-id ${{ steps.find-compartment-id.outputs.raw_output }}'
69+
query: 'data[*].{name: \"display-name\", shape: shape}'
7870

7971
- name: List the display name and shape of the instances in my compartment
8072
run: |
8173
echo ${{ steps.find-my-compartment-instances.outputs.output }} | jq .
8274
```
8375
84-
See [`action.yml`](./action.yml) for more details.
76+
Consult the [JMESPath documentation][4] for details on how to create more complex queries and result formatting and [`action.yml`](./action.yml) for more detail on how to configure this action..
8577

8678
## Contributing
8779

@@ -103,3 +95,4 @@ Released under the Universal Permissive License v1.0 as shown at
10395
[1]: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/clienvironmentvariables.htm
10496
[2]: https://docs.github.com/en/actions/learn-github-actions/environment-variables
10597
[3]: https://docs.oracle.com/en-us/iaas/tools/oci-cli/3.2.0/oci_cli_docs/
98+
[4]: https://jmespath.org/

0 commit comments

Comments
 (0)