Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions .github/workflows/stackql-deploy-actions-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

# Run tests sequentially to avoid race conditions on shared AWS resources.
# Order: Linux amd64 → Linux arm64 → macOS arm → macOS Intel → Windows
# Order: Linux amd64 -> env_vars multi-line (Linux amd64) -> Linux arm64 -> macOS arm -> macOS Intel -> Windows

jobs:
test-ubuntu-latest:
Expand Down Expand Up @@ -67,9 +67,58 @@ jobs:
env_vars: 'AWS_REGION=${{ vars.AWS_REGION }}'
log_level: 'info'

test-env-vars-multiline:
name: "Test env_vars multi-line parsing (ubuntu-latest)"
needs: test-ubuntu-latest
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}
steps:
- uses: actions/checkout@v6
# Uses a `|` block scalar with AWS_REGION on a non-first line so leading-whitespace
# on continuation entries would break the required var if the parser didn't trim.
# UNUSED_* pairs are noise entries the stack does not consume; their presence validates
# that multi-line parsing tolerates additional vars without affecting the stack.
- name: Deploy SSM Parameter (multi-line env_vars)
uses: ./
with:
command: 'build'
stack_dir: 'examples/aws-ssm-parameter'
stack_env: 'dev'
env_vars: |
UNUSED_FIRST=first
AWS_REGION=${{ vars.AWS_REGION }}
UNUSED_LAST=last
log_level: 'info'
- name: Test SSM Parameter (multi-line env_vars)
uses: ./
with:
command: 'test'
stack_dir: 'examples/aws-ssm-parameter'
stack_env: 'dev'
env_vars: |
UNUSED_FIRST=first
AWS_REGION=${{ vars.AWS_REGION }}
UNUSED_LAST=last
log_level: 'info'
- name: Teardown SSM Parameter (multi-line env_vars)
if: always()
uses: ./
with:
command: 'teardown'
stack_dir: 'examples/aws-ssm-parameter'
stack_env: 'dev'
env_vars: |
UNUSED_FIRST=first
AWS_REGION=${{ vars.AWS_REGION }}
UNUSED_LAST=last
log_level: 'info'

test-ubuntu-arm:
name: "Test (ubuntu-24.04-arm)"
needs: test-ubuntu-latest
needs: test-env-vars-multiline
runs-on: ubuntu-24.04-arm
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Authentication to StackQL providers is done via environment variables source fro
- **`command`** - stackql-deploy command to run (__`build`__ or __`test`__)
- **`stack_dir`** - repo directory containing `stackql_manifest.yml` and `resources` dir
- **`stack_env`** - environment to deploy or test (e.g., `dev`, `prod`)
- **`env_vars`** - (optional) environment variables or secrets imported into a stack (format: __`KEY=value,KEY2=value2`__)
- **`env_vars`** - (optional) environment variables or secrets imported into a stack. Accepts a comma-separated string (__`KEY=value,KEY2=value2`__) or a newline-separated YAML block scalar (see the multi-line example below)
- **`env_file`** - (optional) environment variables sourced from a file
- **`show_queries`** - (optional) show queries run in the output logs
- **`log_level`** - (optional) set the logging level (__`INFO`__ or __`DEBUG`__, defaults to __`INFO`__)
Expand Down Expand Up @@ -46,14 +46,37 @@ jobs:
uses: actions/checkout@v6

- name: Deploy a Stack
uses: stackql/stackql-deploy-action@v1.0.2
uses: stackql/stackql-deploy-action@v2
with:
command: 'build'
stack_dir: 'examples/k8s-the-hard-way'
stack_env: 'dev'
env_vars: 'GOOGLE_PROJECT=stackql-k8s-the-hard-way-demo'
```

### Deploy a stack with many env vars (multi-line form)

for stacks that consume many environment variables, `env_vars` also accepts a newline-separated block scalar (`|`). this is easier to read and review than a single comma-separated line:

```yaml
...
- name: Deploy Workspace
uses: stackql/stackql-deploy-action@v2
with:
command: 'build'
stack_dir: 'infrastructure'
stack_env: 'dev'
env_vars: |
AWS_REGION=ap-southeast-2
DATABRICKS_ACCOUNT_ID=${{ env.DATABRICKS_ACCOUNT_ID }}
DATABRICKS_AWS_ACCOUNT_ID=${{ env.DATABRICKS_AWS_ACCOUNT_ID }}
AWS_ACCOUNT_ID=${{ env.AWS_ACCOUNT_ID }}
GIT_REPOSITORY_URL=${{ env.GIT_REPOSITORY_URL }}
GIT_PAT=${{ env.GIT_PAT }}
```

the comma-separated form continues to work unchanged.

### Deploy a stack with outputs

this example shows how to deploy a stack and capture outputs for use in subsequent steps:
Expand All @@ -73,7 +96,7 @@ jobs:

- name: Deploy a Stack
id: stackql-deploy
uses: stackql/stackql-deploy-action@v1.0.2
uses: stackql/stackql-deploy-action@v2
with:
command: 'build'
stack_dir: 'examples/k8s-the-hard-way'
Expand Down Expand Up @@ -105,7 +128,7 @@ this example shows how to test stack for a given environment:
```yaml
...
- name: Test a Stack
uses: stackql/stackql-deploy-action@v1.0.2
uses: stackql/stackql-deploy-action@v2
with:
command: 'test'
stack_dir: 'examples/k8s-the-hard-way'
Expand Down
9 changes: 8 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,17 @@ runs:
fi

# Build env var options (-e KEY=VALUE ...)
# Accepts comma-separated, newline-separated (YAML `|` block), or folded (`>-`) input.
# Newlines are normalized to commas, then each pair is trimmed of surrounding whitespace.
ENV_OPTS=""
if [ -n "${{ inputs.env_vars }}" ]; then
IFS=',' read -r -a env_array <<< "${{ inputs.env_vars }}"
raw_env_vars="${{ inputs.env_vars }}"
raw_env_vars="${raw_env_vars//$'\n'/,}"
IFS=',' read -r -a env_array <<< "$raw_env_vars"
for env_var in "${env_array[@]}"; do
env_var="${env_var#"${env_var%%[![:space:]]*}"}"
env_var="${env_var%"${env_var##*[![:space:]]}"}"
[ -z "$env_var" ] && continue
ENV_OPTS+=" -e $env_var"
done
fi
Expand Down