Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
add deploy (render only) option
Browse files Browse the repository at this point in the history
  • Loading branch information
darrylmendillo committed Dec 16, 2020
1 parent bee3910 commit 145dd0f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -23,3 +27,4 @@ runs:
- ${{ inputs.nomad_addr }}
- ${{ inputs.version }}
- ${{ inputs.config }}
- ${{ inputs.deploy }}
29 changes: 17 additions & 12 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
fi

0 comments on commit 145dd0f

Please sign in to comment.