-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jason Lubken
committed
Sep 23, 2024
1 parent
422117a
commit c25ba7a
Showing
6 changed files
with
198 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,39 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
set -euo pipefail | ||
|
||
function usage { | ||
echo "" | ||
echo "Consul configuration put." | ||
echo "" | ||
echo "usage: --src ./predict/local/configuration.yaml --dst organization/application/predict/configuration.yaml" | ||
echo "" | ||
echo " --src -s string path to configuration file" | ||
echo " --dst -d string path to consul kv" | ||
echo " --help -t Print usage and exit" | ||
echo "" | ||
cat << EOF | ||
Usage: $0 [options] | ||
Options: | ||
-s, --src string Path to configuration file | ||
(example: ./predict/local/configuration.yaml) | ||
-d, --dst string Path to consul key value | ||
(example: organization/application/predict/configuration.yaml | ||
-h, --help Print this help and exit | ||
EOF | ||
} | ||
|
||
while [ $# -gt 0 ]; do | ||
while (( "$#" )); do | ||
case "$1" in | ||
-h|--help) | ||
usage | ||
exit 0 | ||
;; | ||
-d|--dst) | ||
dst="$2" | ||
;; | ||
shift 2 | ||
;; | ||
-s|--src) | ||
src="$2" | ||
;; | ||
shift 2 | ||
;; | ||
-h|--help) | ||
usage | ||
exit 0 | ||
;; | ||
*) | ||
invalid_parameter $1 | ||
echo "Error: Invalid argument $1" >&2 | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
shift | ||
done | ||
|
||
consul kv put ${dst} @${src} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
usage() { | ||
cat << EOF | ||
Usage: $0 [options] | ||
Options: | ||
-r, --ref string GitHub ref (default: GITHUB_REF env var) | ||
-s, --sha string GitHub SHA (default: GITHUB_SHA env var) | ||
-h, --help Print this help and exit | ||
If not provided via command-line arguments, GITHUB_REF and GITHUB_SHA | ||
must be set in the environment. | ||
EOF | ||
} | ||
|
||
# Parse command line arguments | ||
while (( "$#" )); do | ||
case "$1" in | ||
-r|--ref) | ||
ref="$2" | ||
shift 2 | ||
;; | ||
-s|--sha) | ||
sha="$2" | ||
shift 2 | ||
;; | ||
-h|--help) | ||
usage | ||
exit 0 | ||
;; | ||
*) | ||
echo "Error: Invalid argument $1" >&2 | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Set variable, fail if it is not provided and not in the environment | ||
ref="${ref:=$GITHUB_REF}" | ||
deploy="" | ||
|
||
if [[ "$ref" == refs/tags/* ]]; then | ||
version=$(basename "$ref") | ||
regex="^[0-9]+\.[0-9]+\.[0-9]+(-(rc|evaluation)\.([0-9]+))?$" | ||
# Check if the version matches semantic versioning pattern | ||
if [[ $version =~ $regex ]]; then | ||
# Extract deploy from the version | ||
deploy="${BASH_REMATCH[2]}" | ||
if [[ $deploy == "" ]]; then | ||
deploy="live" | ||
fi | ||
fi | ||
else | ||
# Set variable, fail if it is not provided and not in the environment | ||
sha="${sha:=$GITHUB_SHA}" | ||
version="$sha" | ||
fi | ||
|
||
# Output variables in GitHub Actions output format | ||
echo "version=${version}" | ||
echo "deploy=${deploy}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.