|
| 1 | +name: 'stackql-deploy' |
| 2 | +description: 'Deploy and test stacks using stackql-deploy' |
| 3 | +inputs: |
| 4 | + command: |
| 5 | + description: 'stackql-deploy command to run (`build` or `test`)' |
| 6 | + required: true |
| 7 | + stack_dir: |
| 8 | + description: 'repo directory containing `stackql_manifest.yml` and `resources` dir' |
| 9 | + required: true |
| 10 | + stack_env: |
| 11 | + description: 'environment to deploy or test (e.g., `dev`, `prod`)' |
| 12 | + required: true |
| 13 | + env_vars: |
| 14 | + description: 'environment variables or secrets imported into a stack (format: `KEY=value,KEY2=value2`)' |
| 15 | + required: false |
| 16 | + env_file: |
| 17 | + description: 'environment variables sourced from a file' |
| 18 | + required: false |
| 19 | + show_queries: |
| 20 | + description: 'show queries run in the output logs' |
| 21 | + required: false |
| 22 | + log_level: |
| 23 | + description: 'set the logging level (`INFO` or `DEBUG`, defaults to `INFO`)' |
| 24 | + required: false |
| 25 | + dry_run: |
| 26 | + description: 'perform a dry run of the operation' |
| 27 | + required: false |
| 28 | + custom_registry: |
| 29 | + description: 'custom registry URL to be used for stackql' |
| 30 | + required: false |
| 31 | + on_failure: |
| 32 | + description: 'action on failure' |
| 33 | + required: false |
| 34 | + |
| 35 | +runs: |
| 36 | + using: 'composite' |
| 37 | + steps: |
| 38 | + - name: Install Python |
| 39 | + |
| 40 | + with: |
| 41 | + python-version: '3.10' |
| 42 | + |
| 43 | + - name: Install stackql-deploy |
| 44 | + shell: bash |
| 45 | + run: pip install -q stackql-deploy pyyaml || { echo "pip install failed"; exit 1; } |
| 46 | + |
| 47 | + - name: Run stackql-deploy |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + ENV_OPTS="" |
| 51 | + if [ -n "${{ inputs.env_vars }}" ]; then |
| 52 | + IFS=',' read -r -a env_array <<< "${{ inputs.env_vars }}" |
| 53 | + for env_var in "${env_array[@]}"; do |
| 54 | + ENV_OPTS+=" -e $env_var" |
| 55 | + done |
| 56 | + fi |
| 57 | +
|
| 58 | + STACKQL_DEPLOY_CMD="stackql-deploy ${{ inputs.command }} ${{ inputs.stack_dir }} ${{ inputs.stack_env }}" |
| 59 | +
|
| 60 | + if [ -n "${{ inputs.env_file }}" ]; then |
| 61 | + STACKQL_DEPLOY_CMD+=" --env-file ${{ inputs.env_file }}" |
| 62 | + fi |
| 63 | + if [ "${{ inputs.show_queries }}" == "true" ]; then |
| 64 | + STACKQL_DEPLOY_CMD+=" --show-queries" |
| 65 | + fi |
| 66 | + if [ -n "${{ inputs.log_level }}" ]; then |
| 67 | + STACKQL_DEPLOY_CMD+=" --log-level ${{ inputs.log_level }}" |
| 68 | + fi |
| 69 | + if [ "${{ inputs.dry_run }}" == "true" ]; then |
| 70 | + STACKQL_DEPLOY_CMD+=" --dry-run" |
| 71 | + fi |
| 72 | + if [ -n "${{ inputs.custom_registry }}" ]; then |
| 73 | + STACKQL_DEPLOY_CMD+=" --custom-registry ${{ inputs.custom_registry }}" |
| 74 | + fi |
| 75 | + if [ -n "${{ inputs.on_failure }}" ]; then |
| 76 | + STACKQL_DEPLOY_CMD+=" --on-failure ${{ inputs.on_failure }}" |
| 77 | + fi |
| 78 | +
|
| 79 | + echo "executing: $STACKQL_DEPLOY_CMD $ENV_OPTS" |
| 80 | + $STACKQL_DEPLOY_CMD $ENV_OPTS |
| 81 | +
|
| 82 | +branding: |
| 83 | + icon: 'server' |
| 84 | + color: 'blue' |
0 commit comments