Skip to content

Commit

Permalink
BUILD-7112 skip if no version found
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-carsique-sonarsource committed Dec 18, 2024
1 parent 12c2b2f commit b56f3eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
11 changes: 1 addition & 10 deletions releasability-status/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,12 @@ runs:
run: pip install pipenv
shell: bash

- uses: octokit/request-action@dad4362715b7fb2ddedf9772c8670824af564f0d # v2.4.0
id: get_commit_status
with:
route: 'GET /repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/commits/${{ github.sha }}/status'
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}

# Find latest promoted version from the commit status
- id: find_version
shell: bash
working-directory: ${{ github.action_path }}
env:
OUTPUTS: "${{ steps.get_commit_status.outputs.data }}"
run: |
./find_version.sh ${{ github.ref_name }}
./find_version.sh
- name: Trigger releasability checks
id: checks
Expand Down
25 changes: 9 additions & 16 deletions releasability-status/find_version.sh
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"

0 comments on commit b56f3eb

Please sign in to comment.