Skip to content

Commit

Permalink
fix: support for comma separated list of commits & deliverables
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienFromToulouse committed Oct 28, 2024
1 parent 69836cd commit 60f4aa5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ See [Examples](#examples) below for more details.
with:
# Optional. Can either be `post-deploy` or `post-status`. Defaults to `post-deploy`.
action-type: string
# Required. Newline-separated list of deliverables the deployment contains (e.g., microservice name, application name). Defaults to repository name.
# Required. Newline-separated or comma-separated list of deliverables the deployment contains (e.g., microservice name, application name). Defaults to repository name.
deliverables: string
# Required. Newline-separated list of commits SHA shipped as part of the deployment. Defaults to listing commits between the last 2 tags or as a last fallback $GITHUB_SHA.
# Required. Newline-separated or comma-separated list of commits SHA shipped as part of the deployment. Defaults to listing commits between the last 2 tags or as a last fallback $GITHUB_SHA.
commits: string
# Optional. Version being deployed.
version: string
Expand Down
22 changes: 20 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,28 @@ while getopts ":t:v:d:c:u:s:i:" opt; do
v) version=$(trim "${OPTARG}")
;;
d)
mapfile -t deliverables < <(trim "${OPTARG}")
if [[ "${OPTARG}" =~ ^([^,]+,)+[^,]+$ ]]; then # Support coma separeted list of deliverables
IFS=',' read -r -a raw_deliverables <<< "${OPTARG}"
deliverables=()
for deliverable in "${raw_deliverables[@]}"; do
trimmed_deliverable=$(trim "$deliverable")
deliverables+=("$trimmed_deliverable")
done
else
mapfile -t deliverables < <(trim "${OPTARG}") # Support Newline-separated list of deliverables
fi
;;
c)
mapfile -t commits < <(trim "${OPTARG}")
if [[ "${OPTARG}" =~ ^([^,]+,)+[^,]+$ ]]; then # Support coma separeted list of commits
IFS=',' read -r -a raw_commits <<< "${OPTARG}"
commits=()
for commit in "${raw_commits[@]}"; do
trimmed_commit=$(trim "$commit")
commits+=("$trimmed_commit")
done
else
mapfile -t commits < <(trim "${OPTARG}") # Support Newline-separated list of commits
fi
;;
u) url=$(trim "${OPTARG}")
;;
Expand Down

0 comments on commit 60f4aa5

Please sign in to comment.