Skip to content

Commit f425427

Browse files
committed
updated README
1 parent 9484f89 commit f425427

File tree

1 file changed

+58
-21
lines changed

1 file changed

+58
-21
lines changed

README.md

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,28 @@ Github Action as a wrapper for executing a single command in stackql, maps all s
66
## Provider Authentication
77
Authentication to StackQL providers is done via environment variables source from GitHub Actions Secrets. To learn more about authentication, see the setup instructions for your provider or providers at the [StackQL Provider Registry Docs](https://stackql.io/registry).
88

9-
# Examples
10-
## Query Example
11-
```
9+
## Inputs
10+
- `query` - stackql query to execute **(need to supply either `query` or `query_file_path`)**
11+
- `query_file_path` - stackql query file to execute **(need to supply either `query` or `query_file_path`)**
12+
- `data_file_path` - (optional) path to data file to pass to the stackql query preprocessor (`json` or `jsonnet`)
13+
- `vars` - (optional) comma delimited list of variables to pass to the stackql query preprocessor (supported with `jsonnet` config blocks or `jsonnet` data files only), accepts `var1=val1,var2=val2`, can be used to source environment variables into stackql queries
14+
- `query_output` - (optional) output format of the stackql exec result, accepts `table`, `csv`, `json`, defaults to `json`
15+
- `auth_obj_path` - (optional) the path of json file that stores stackql AUTH string **(only required when using non-standard environment variable names)**
16+
- `auth_str` - (optional) stackql AUTH string **(only required when using non-standard environment variable names)**
17+
18+
19+
## Outputs
20+
This action uses [setup-stackql](https://github.com/marketplace/actions/stackql-studio-setup-stackql), with use_wrapper set
21+
to `true`, `stdout` and `stderr` are set to `exec-result` and `exec-error`
22+
23+
- `exec-result` - The STDOUT stream of the call to the `stackql` binary.
24+
- `exec-error` - The STDERR stream of the call to the `stackql` binary.
25+
26+
## Examples
27+
28+
### Inline `stackql` query example
29+
30+
```yaml
1231
- name: exec github example
1332
uses: ./
1433
with:
@@ -22,9 +41,9 @@ Authentication to StackQL providers is done via environment variables source fro
2241
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}
2342
```
2443
44+
### Query file example using an inline `jsonnet` variable block and external variables
2545

26-
## Query File example
27-
- `google-example.iql`
46+
`google-example.iql`
2847
```
2948
<<<jsonnet
3049
local project = std.extVar("GOOGLE_PROJECT");
@@ -39,8 +58,9 @@ FROM google.compute.instances
3958
WHERE project = '{{ .project }}' and zone = '{{ .zone }}'
4059
GROUP BY status;
4160
```
42-
**Example**
43-
```
61+
62+
workflow excerpt:
63+
```yaml
4464
- name: exec google example with query file using vars
4565
id: stackql-exec-file-with-vars
4666
uses: ./
@@ -53,23 +73,40 @@ GROUP BY status;
5373
GOOGLE_ZONE: ${{ vars.GOOGLE_ZONE }}
5474
```
5575

56-
## Inputs
57-
- `query` - stackql query to execute **(need to supply either `query` or `query_file_path`)**
58-
- `query_file_path` - stackql query file to execute **(need to supply either `query` or `query_file_path`)**
59-
- `data_file_path` - (optional) path to data file to pass to the stackql query preprocessor (`json` or `jsonnet`)
60-
- `vars` - (optional) comma delimited list of variables to pass to the stackql query preprocessor (supported with `jsonnet` config blocks or `jsonnet` data files only), accepts `var1=val1,var2=val2`, can be used to source environment variables into stackql queries
61-
- `query_output` - (optional) output format of the stackql exec result, accepts `table`, `csv`, `json`, defaults to `json`
62-
- `auth_obj_path` - (optional) the path of json file that stores stackql AUTH string **(only required when using non-standard environment variable names)**
63-
- `auth_str` - (optional) stackql AUTH string **(only required when using non-standard environment variable names)**
64-
76+
### Query file example using an external `jsonnet` data file and external variables
6577

66-
## Outputs
67-
This action uses [setup-stackql](https://github.com/marketplace/actions/stackql-studio-setup-stackql), with use_wrapper set
68-
to `true`, `stdout` and `stderr` are set to `exec-result` and `exec-error`
78+
`google-example.iql`
79+
```sql
80+
SELECT status, count(*) as num_instances
81+
FROM google.compute.instances
82+
WHERE project = '{{ .project }}' and zone = '{{ .zone }}'
83+
GROUP BY status;
84+
```
6985

70-
- `exec-result` - The STDOUT stream of the call to the `stackql` binary.
71-
- `exec-error` - The STDERR stream of the call to the `stackql` binary.
86+
`google-example.jsonnet`
87+
```
88+
local project = std.extVar("GOOGLE_PROJECT");
89+
local zone = std.extVar("GOOGLE_ZONE");
90+
{
91+
project: project,
92+
zone: zone,
93+
}
94+
```
7295

96+
workflow excerpt:
97+
```yaml
98+
- name: exec google example with query file and data file using vars
99+
id: stackql-exec-file-with-data-file-and-vars
100+
uses: ./
101+
with:
102+
query_file_path: './stackql_scripts/google-example.iql'
103+
data_file_path: './stackql_scripts/google-example.jsonnet'
104+
vars: GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }}
105+
env:
106+
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
107+
GOOGLE_PROJECT: ${{ vars.GOOGLE_PROJECT }}
108+
GOOGLE_ZONE: ${{ vars.GOOGLE_ZONE }}
109+
```
73110
## Test action locally
74111
To run unit tests locally against this action, use the following:
75112

0 commit comments

Comments
 (0)