-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
187 lines (167 loc) · 7.07 KB
/
action.yml
File metadata and controls
187 lines (167 loc) · 7.07 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: 'stackql-deploy'
description: 'Deploy and test stacks using stackql-deploy (Rust edition)'
inputs:
command:
description: 'stackql-deploy command to run (`build`, `test`, `teardown`, or `info`)'
required: true
stack_dir:
description: 'repo directory containing `stackql_manifest.yml` and `resources` dir'
required: false
stack_env:
description: 'environment to deploy or test (e.g., `dev`, `prod`)'
required: false
env_vars:
description: 'environment variables or secrets imported into a stack (format: `KEY=value,KEY2=value2`)'
required: false
env_file:
description: 'environment variables sourced from a file'
required: false
show_queries:
description: 'show queries run in the output logs'
required: false
log_level:
description: 'set the logging level (`info`, `debug`, `trace`, `warn`, or `error`, defaults to `info`)'
required: false
dry_run:
description: 'perform a dry run of the operation'
required: false
on_failure:
description: 'action on failure (`error`, `rollback`, or `ignore`, defaults to `error`)'
required: false
show_info:
description: 'show stackql-deploy info output before running the command'
required: false
output_file:
description: 'output file to capture deployment outputs as JSON (supported for `build` command only)'
required: false
outputs:
deployment_outputs:
description: 'JSON string containing all deployment outputs from stackql-deploy'
value: ${{ steps.stackql-deploy.outputs.deployment_outputs }}
runs:
using: 'composite'
steps:
- name: Install stackql-deploy
shell: bash
run: |
if command -v stackql-deploy &> /dev/null; then
echo "stackql-deploy already installed: $(stackql-deploy --version 2>/dev/null || echo 'version unknown')"
else
echo "Installing stackql-deploy binary..."
OS="$(uname -s)"
ARCH="$(uname -m)"
BASE_URL="https://github.com/stackql/stackql-deploy-rs/releases/latest/download"
echo "Detected platform: ${OS}-${ARCH}"
case "${OS}-${ARCH}" in
Linux-x86_64) URL="${BASE_URL}/stackql-deploy-linux-x86_64.tar.gz" ;;
Linux-aarch64) URL="${BASE_URL}/stackql-deploy-linux-arm64.tar.gz" ;;
Darwin-arm64) URL="${BASE_URL}/stackql-deploy-macos-arm64.tar.gz" ;;
Darwin-x86_64) URL="${BASE_URL}/stackql-deploy-macos-x86_64.tar.gz" ;;
MINGW*|MSYS*|CYGWIN*)
URL="${BASE_URL}/stackql-deploy-windows-x86_64.zip" ;;
*)
echo "Unsupported platform: ${OS}-${ARCH}"
exit 1
;;
esac
echo "Download URL: ${URL}"
if [[ "$OS" == MINGW* || "$OS" == MSYS* || "$OS" == CYGWIN* ]]; then
curl -L -o stackql-deploy.zip "$URL"
unzip -o stackql-deploy.zip
rm -f stackql-deploy.zip
else
curl -L "$URL" | tar -xz
fi
chmod +x ./stackql-deploy
echo "Binary details: $(file ./stackql-deploy)"
echo "${GITHUB_WORKSPACE}" >> "$GITHUB_PATH"
export PATH="${GITHUB_WORKSPACE}:${PATH}"
echo "stackql-deploy installed:"
./stackql-deploy info
fi
- name: Run stackql-deploy
id: stackql-deploy
shell: bash
run: |
# Show stackql-deploy info if requested
if [ "${{ inputs.show_info }}" == "true" ]; then
echo "Running stackql-deploy info..."
stackql-deploy info
echo ""
fi
# Handle info command (no stack_dir/stack_env needed)
if [ "${{ inputs.command }}" == "info" ]; then
stackql-deploy info
exit 0
fi
# Build env var options (-e KEY=VALUE ...)
ENV_OPTS=""
if [ -n "${{ inputs.env_vars }}" ]; then
IFS=',' read -r -a env_array <<< "${{ inputs.env_vars }}"
for env_var in "${env_array[@]}"; do
ENV_OPTS+=" -e $env_var"
done
fi
STACKQL_DEPLOY_CMD="stackql-deploy ${{ inputs.command }}"
# Append positional args only when provided
if [ -n "${{ inputs.stack_dir }}" ]; then
STACKQL_DEPLOY_CMD+=" ${{ inputs.stack_dir }}"
fi
if [ -n "${{ inputs.stack_env }}" ]; then
STACKQL_DEPLOY_CMD+=" ${{ inputs.stack_env }}"
fi
if [ -n "${{ inputs.env_file }}" ]; then
STACKQL_DEPLOY_CMD+=" --env-file ${{ inputs.env_file }}"
fi
if [ "${{ inputs.show_queries }}" == "true" ]; then
STACKQL_DEPLOY_CMD+=" --show-queries"
fi
if [ -n "${{ inputs.log_level }}" ]; then
STACKQL_DEPLOY_CMD+=" --log-level ${{ inputs.log_level }}"
fi
if [ "${{ inputs.dry_run }}" == "true" ]; then
STACKQL_DEPLOY_CMD+=" --dry-run"
fi
if [ -n "${{ inputs.on_failure }}" ]; then
STACKQL_DEPLOY_CMD+=" --on-failure ${{ inputs.on_failure }}"
fi
# --output-file is only supported by the build command
OUTPUT_FILE=""
if [ -n "${{ inputs.output_file }}" ] && [ "${{ inputs.command }}" == "build" ]; then
OUTPUT_FILE="${{ inputs.output_file }}"
STACKQL_DEPLOY_CMD+=" --output-file $OUTPUT_FILE"
fi
echo "executing: $STACKQL_DEPLOY_CMD $ENV_OPTS"
# Run command and capture exit code
set +e
$STACKQL_DEPLOY_CMD $ENV_OPTS
EXIT_CODE=$?
set -e
# Handle failure
if [ $EXIT_CODE -ne 0 ]; then
echo "## ❌ StackQL Deploy ${{ inputs.command }} Failed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Environment:** ${{ inputs.stack_env }}" >> $GITHUB_STEP_SUMMARY
echo "**Stack Directory:** ${{ inputs.stack_dir }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Please check the logs above for details." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "_Failed at $(date -u +'%Y-%m-%d %H:%M:%S UTC')_" >> $GITHUB_STEP_SUMMARY
exit $EXIT_CODE
fi
# Capture outputs if output file was specified (build command, success path)
if [ -n "$OUTPUT_FILE" ] && [ -f "$OUTPUT_FILE" ]; then
DEPLOYMENT_OUTPUTS=$(cat "$OUTPUT_FILE")
echo "deployment_outputs<<EOF" >> $GITHUB_OUTPUT
echo "$DEPLOYMENT_OUTPUTS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "## 📦 StackQL Deploy ${{ inputs.command }}:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "$DEPLOYMENT_OUTPUTS" | jq -r 'to_entries[] | "**\(.key):** \(.value)"' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "_Completed at $(date -u +'%Y-%m-%d %H:%M:%S UTC')_" >> $GITHUB_STEP_SUMMARY
echo "Deployment outputs captured successfully"
fi
branding:
icon: 'server'
color: 'blue'