Github Action as a wrapper for executing a single command in stackql, maps all stackql exec args to actions args
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.
query
- stackql query to execute (need to supply eitherquery
orquery_file_path
)query_file_path
- stackql query file to execute (need to supply eitherquery
orquery_file_path
)data_file_path
- (optional) path to data file to pass to the stackql query preprocessor (json
orjsonnet
)dry_run
- (optional) set totrue
to print the query that would be executed without actually executing it (default isfalse
)vars
- (optional) comma delimited list of variables to pass to the stackql query preprocessor (supported withjsonnet
config blocks orjsonnet
data files only), acceptsvar1=val1,var2=val2
, can be used to source environment variables into stackql queriesquery_output
- (optional) output format of the stackql exec result, acceptstable
,csv
,json
andtext
, defaults tojson
auth_obj_path
- (optional) the path of json file that stores stackql AUTH string (only required when using non-standard environment variable names)auth_str
- (optional) stackql AUTH string (only required when using non-standard environment variable names)is_command
- (optional) set totrue
if the stackql execution is a command that does not return data (defaults tofalse
)on_failure
- (optional) behavior on a failure in query, supported values areexit
(default) andcontinue
stackql-query-results
- results from a stackql query (in the format specified)stackql-command-output
- text output from a stackql command (a query that does not return data)stackql-query-error
- error from a stackql query
This action uses setup-stackql
this is an example of a command (that does not return data):
- name: exec github example
uses: ./
with:
is_command: 'true'
query: "REGISTRY PULL github;
env:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}
this is an example of a query that returns data:
- name: exec github example
uses: ./
with:
query: |
select total_private_repos
from github.orgs.orgs
where org = 'stackql'"
env:
STACKQL_GITHUB_USERNAME: ${{ secrets.STACKQL_GITHUB_USERNAME }}
STACKQL_GITHUB_PASSWORD: ${{ secrets.STACKQL_GITHUB_PASSWORD }}
google-example.iql
<<<jsonnet
local project = std.extVar("GOOGLE_PROJECT");
local zone = std.extVar("GOOGLE_ZONE");
{
project: project,
zone: zone,
}
>>>
SELECT status, count(*) as num_instances
FROM google.compute.instances
WHERE project = '{{ .project }}' and zone = '{{ .zone }}'
GROUP BY status;
workflow excerpt:
- name: exec google example with query file using vars
id: stackql-exec-file-with-vars
uses: ./
with:
query_file_path: './stackql_scripts/google-example.iql'
vars: GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }}
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
GOOGLE_PROJECT: ${{ vars.GOOGLE_PROJECT }}
GOOGLE_ZONE: ${{ vars.GOOGLE_ZONE }}
google-example.iql
SELECT status, count(*) as num_instances
FROM google.compute.instances
WHERE project = '{{ .project }}' and zone = '{{ .zone }}'
GROUP BY status;
google-example.jsonnet
local project = std.extVar("GOOGLE_PROJECT");
local zone = std.extVar("GOOGLE_ZONE");
{
project: project,
zone: zone,
}
workflow excerpt:
- name: exec google example with query file and data file using vars
id: stackql-exec-file-with-data-file-and-vars
uses: ./
with:
query_file_path: './stackql_scripts/google-example.iql'
data_file_path: './stackql_scripts/google-example.jsonnet'
vars: GOOGLE_PROJECT=${{ env.GOOGLE_PROJECT }},GOOGLE_ZONE=${{ env.GOOGLE_ZONE }}
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
GOOGLE_PROJECT: ${{ vars.GOOGLE_PROJECT }}
GOOGLE_ZONE: ${{ vars.GOOGLE_ZONE }}
To run unit tests locally against this action, use the following:
npm i
npm run test lib/tests/utils.test.js