-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
119 lines (113 loc) · 4.43 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: 'stackql-exec'
description: 'A wrapper for executing a single command, maps all stackql exec args to actions args (supplied using with.)'
author: 'Yuncheng Yang, StackQL Studios'
inputs:
query:
description: stackql query to be executed
required: false
query_file_path:
description: stackql query file to be executed
required: false
data_file_path:
description: jsonnet or json data file to be passed to query preprocessor
required: false
dry_run:
description: set to true to print the query that would be executed without actually executing it (default is false)
required: false
default: 'false'
vars:
description: comma delimited list of vars to be passed to query preprocessor (supported with jsonnet config blocks or jsonnet data files only)
required: false
query_output:
description: output format for queries (ignored is `is_command` is `true`), supported formats include `json` (default), `csv`, `table` and `text`
default: 'json'
required: false
auth_obj_path:
description: file path to json object of stackql auth, not required if using standard provider authentication environment variables
required: false
auth_str:
description: json string of stackql auth, not required if using standard provider authentication environment variables
required: false
is_command:
description: "Set to true if the stackql execution is a command that does not return data"
required: false
default: 'false'
on_failure:
description: behavior on a failure in query, supported values are `exit` (default) and `continue`
required: false
default: 'exit'
outputs:
stackql-query-results:
description: results from a stackql query (in the format specified)
value: ${{ steps.exec-stackql.outputs.stackql-query-results }}
stackql-command-output:
description: text output from a stackql command (a query that does not return data)
value: ${{ steps.exec-stackql.outputs.stackql-command-output }}
stackql-query-error:
description: error from a stackql query
value: ${{ steps.exec-stackql.outputs.stackql-query-error }}
runs:
using: "composite"
steps:
- name: Check StackQL is installed and set output
id: check-stackql
shell: bash
run: |
if command -v stackql &> /dev/null; then
echo "stackql_installed=true" >> $GITHUB_OUTPUT
else
echo "stackql_installed=false" >> $GITHUB_OUTPUT
fi
- name: Setup StackQL
uses: stackql/[email protected]
if: ${{steps.check-stackql.outputs.stackql_installed == 'false'}}
with:
use_wrapper: true
- name: Validate Stackql Version
shell: bash
run: |
stackql --version
- name: Setup auth
id: setup-auth
uses: actions/[email protected]
with:
script: |
const path = require('path');
const utilsPath = path.join(process.env.GITHUB_ACTION_PATH, 'lib', 'utils.js')
const {setupAuth} = require(utilsPath)
setupAuth(core)
env:
AUTH_FILE_PATH: ${{ inputs.auth_obj_path }}
AUTH_STR: ${{inputs.auth_str}}
- name: get stackql command
uses: actions/[email protected]
with:
script: |
const path = require('path');
const utilsPath = path.join(process.env.GITHUB_ACTION_PATH, 'lib', 'utils.js')
const {getStackqlCommand} = require(utilsPath)
getStackqlCommand(core)
env:
QUERY_FILE_PATH: ${{ inputs.query_file_path }}
QUERY: ${{inputs.query}}
DATA_FILE_PATH: ${{inputs.data_file_path}}
DRY_RUN: ${{inputs.dry_run}}
OUTPUT: ${{inputs.query_output}}
VARS: ${{inputs.vars}}
- name: execute stackql command
uses: actions/[email protected]
id: exec-stackql
with:
script: |
const path = require('path');
const utilsPath = path.join(process.env.GITHUB_ACTION_PATH, 'lib', 'utils.js')
const {execStackQLQuery} = require(utilsPath);
const onFailure = process.env.ON_FAILURE || 'exit'; // default to 'exit' if not specified
await execStackQLQuery(core, process.env.STACKQL_COMMAND, process.env.IS_COMMAND === 'true', onFailure, process.env.DRY_RUN === 'true');
env:
IS_COMMAND: ${{ inputs.is_command }}
DRY_RUN: ${{ inputs.dry_run }}
ON_FAILURE: ${{ inputs.on_failure }}
branding:
icon: 'terminal'
color: 'blue'