Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for comma separated list of commits & deliverables #6

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ author: "EchoesHQ"
description: "Declare deployments and notify their status to Echoes."
inputs:
deliverables:
description: "Newline-separated list of deliverables the deployment contains (e.g., microservice name, application name)..."
description: "Newline-separated or comma-separated list of deliverables the deployment contains (e.g., microservice name, application name)..."
required: false
commits:
description: "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."
description: "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."
required: false
version:
description: "Version being deployed."
Expand Down
26 changes: 24 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,32 @@ while getopts ":t:v:d:c:u:s:i:" opt; do
v) version=$(trim "${OPTARG}")
;;
d)
mapfile -t deliverables < <(trim "${OPTARG}")
deliverables=()

if [[ "${OPTARG}" =~ ^([^,]+,)+[^,]+$ ]]; then # Support comma separated list of deliverables
IFS=',' read -r -a raw_deliverables <<< "${OPTARG}"
else
mapfile -t raw_deliverables < <(echo "${OPTARG}") # Support Newline-separated list of deliverables
fi

for deliverable in "${raw_deliverables[@]}"; do
trimmed_deliverable=$(trim "$deliverable")
deliverables+=("$trimmed_deliverable")
done
;;
c)
mapfile -t commits < <(trim "${OPTARG}")
commits=()

if [[ "${OPTARG}" =~ ^([^,]+,)+[^,]+$ ]]; then # Support comma separated list of commits
IFS=',' read -r -a raw_commits <<< "${OPTARG}"
else
mapfile -t raw_commits < <(echo "${OPTARG}") # Support Newline-separated list of commits
fi

for commit in "${raw_commits[@]}"; do
trimmed_commit=$(trim "$commit")
commits+=("$trimmed_commit")
done
;;
u) url=$(trim "${OPTARG}")
;;
Expand Down
Loading