diff --git a/action.yml b/action.yml index e8c56d9..fa1e7d6 100644 --- a/action.yml +++ b/action.yml @@ -15,6 +15,10 @@ inputs: nomad_addr: description: "target nomad deployment address" required: true + deploy: + description: "deploy the jobs after rendering. False will only render. Default = TRUE" + required: false + default: 'TRUE' runs: using: "docker" @@ -23,3 +27,4 @@ runs: - ${{ inputs.nomad_addr }} - ${{ inputs.version }} - ${{ inputs.config }} + - ${{ inputs.deploy }} diff --git a/entrypoint.sh b/entrypoint.sh index b89e1aa..ecdec47 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,9 +1,12 @@ #!/bin/bash +INPUT_DEPLOY=${INPUT_DEPLOY:-TRUE} + # echo all the variabls echo "INPUT_ADDR: $INPUT_VERSION" echo "INPUT_CONFIG: $INPUT_CONFIG" echo "INPUT_NOMAD_ADDR: $INPUT_NOMAD_ADDR" +echo "INPUT_DEPLOY: $INPUT_DEPLOY" # export NOMAD_ADDR for deployment export "NOMAD_ADDR=$INPUT_NOMAD_ADDR" @@ -27,19 +30,21 @@ for dir in */ ; do done # deploy -for dir in */ ; do - if [ -d "${dir}nomad" ]; then +if [ $INPUT_DEPLOY = "TRUE" ]; then + for dir in */ ; do + if [ -d "${dir}nomad" ]; then - echo "Deploying jobs from: ${dir}nomad." - for file in ${dir}nomad/*; do - matched=$([[ $file =~ ^.*.nomad.hcl$ ]] && echo "true" || echo "false") + echo "Deploying jobs from: ${dir}nomad." + for file in ${dir}nomad/*; do + matched=$([[ $file =~ ^.*.nomad.hcl$ ]] && echo "true" || echo "false") - # only deploy *.nomad.hcl (jobs) - if [ $matched = "true" ]; then - echo "levant deploy -var TAG=${INPUT_VERSION} -ignore-no-changes -var DEPLOY=staging -var-file=${INPUT_CONFIG} ${file}" - levant deploy -var TAG=${INPUT_VERSION} -ignore-no-changes -var DEPLOY=staging -var-file=${INPUT_CONFIG} ${file} - fi + # only deploy *.nomad.hcl (jobs) + if [ $matched = "true" ]; then + echo "levant deploy -var TAG=${INPUT_VERSION} -ignore-no-changes -var DEPLOY=staging -var-file=${INPUT_CONFIG} ${file}" + levant deploy -var TAG=${INPUT_VERSION} -ignore-no-changes -var DEPLOY=staging -var-file=${INPUT_CONFIG} ${file} + fi + done + fi done - fi -done \ No newline at end of file +fi \ No newline at end of file