add dry-run

This commit is contained in:
Muhammad Atif Ali 2023-08-11 13:16:41 +03:00
parent 8be7894259
commit 0b3202d989
3 changed files with 15 additions and 3 deletions

View file

@ -25,6 +25,7 @@ Update coder templates automatically
| `activate` | Activate the new template version. | `true` |
| `create` | Creates a new template if it does not exist | `true` |
| `message` | Update message (similar to commit messages) | - |
| `dry_run` | Dry run mode. | `false` |
## Examples

View file

@ -34,6 +34,10 @@ inputs:
description: "Creates a new template if it does not exist"
required: false
default: "true"
dry_run:
description: "Dry run"
required: false
default: "true" # make it false after testing TODO
runs:
using: "composite"
@ -54,3 +58,4 @@ runs:
CODER_TEMPLATE_ACTIVATE: ${{ inputs.activate }}
CODER_TEMPLATE_MESSAGE: ${{ inputs.message }}
CODER_TEMPLATE_CREATE: ${{ inputs.create }}
CODER_TEMPLATE_DRY_RUN: ${{ inputs.dry_run }}

View file

@ -38,7 +38,13 @@ fi
# Add confirmation flag to the push command
push_command+=" --yes"
# Execute the push command
${push_command}
# Execute the push command if no dry run
if [ "${CODER_TEMPLATE_DRY_RUN}" = "false" ]; then
echo "Pushing ${CODER_TEMPLATE_DIR} to ${CODER_URL}..."
eval ${push_command}
echo "A new version of ${CODER_TEMPLATE_DIR} is pushed to ${CODER_URL} successfully."
exit 0
fi
echo "Dry run is enabled. The following command will be executed:"
echo ${push_command}
echo "A new version of ${CODER_TEMPLATE_DIR} is pushed to ${CODER_URL} successfully."