-
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
1 parent
12c2b2f
commit b56f3eb
Showing
2 changed files
with
10 additions
and
26 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,23 +1,16 @@ | ||
#!/bin/bash | ||
# Find last promoted version from github commit status check results | ||
set -xeuo pipefail | ||
|
||
version="" | ||
# Find last promoted version from GitHub commit status check results: | ||
# "description": "Latest promoted build of '${PROJECT_VERSION}' from branch '${GITHUB_BRANCH}'" | ||
# "context": "repox-${GITHUB_BRANCH}", | ||
|
||
readarray -t statuses < <(echo "$OUTPUTS" | jq -c ".statuses[]") | ||
for i in "${statuses[@]}"; do | ||
desc=$(echo "$i" | jq -r ".description") | ||
v=$(echo "$desc" | cut -d\' -f 2 ) | ||
branch=$(echo "$desc" | cut -d\' -f 4 ) | ||
if [[ $branch == "$1" ]]; then | ||
version=$v | ||
break | ||
fi | ||
done | ||
set -xeuo pipefail | ||
|
||
description=$(gh api "/repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/statuses" \ | ||
--jq '.[] | select(.state == "success" and .context == ("repox-'"$GITHUB_REF_NAME"'")) | .description') | ||
version=$(echo "$description" | cut -d\' -f 2) | ||
if [ -z "${version}" ]; then | ||
echo "Unable to find promoted version" | ||
exit 1 | ||
echo "status=skipped" >> "$GITHUB_OUTPUT" | ||
exit 0 | ||
fi | ||
|
||
echo "version=$version" >> "$GITHUB_OUTPUT" |