Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
simbo committed Sep 7, 2022
1 parent 5c16d05 commit 6b31f21
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,25 @@ runs:
shell: bash
run: |
if [[ "${{ inputs.version }}" = "" ]]; then
valeVersion="$(curl -sL https://api.github.com/repos/errata-ai/vale/releases/latest | grep '"tag_name":' | cut -d \" -f 4 | cut -d v -f 2)"
valeVersionData=$(curl -sfL https://api.github.com/repos/errata-ai/vale/releases/latest)
if [[ "$valeVersionData" = "" ]]; then
echo "::error title=GitHub API Error::Could not retrieve the latest Vale version info from GitHub API."
exit 1
fi
valeVersion="$(printf "$valeVersionData" | grep '"tag_name":' | cut -d \" -f 4 | cut -d v -f 2)"
else
valeVersion="${{ inputs.version }}"
fi
if ! [[ "$valeVersion" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error title=invalid version::vale version '${valeVersion}' is not a valid semver version"
echo "::error title=Invalid Version::The Vale version '${valeVersion}' is not a valid semver version."
exit 1
fi
echo "::group::Vale Installation"
curl -sL https://github.com/errata-ai/vale/releases/download/v${valeVersion}/vale_${valeVersion}_Linux_64-bit.tar.gz -o vale.tar.gz
curl -sfL https://github.com/errata-ai/vale/releases/download/v${valeVersion}/vale_${valeVersion}_Linux_64-bit.tar.gz -o vale.tar.gz
if ! [[ -f vale.tar.gz ]]; then
echo "::error title=Vale Download failed::Downloading the latest Vale version failed."
exit 1
fi
mkdir -p ${RUNNER_TEMP}/bin
tar -xvzf vale.tar.gz -C ${RUNNER_TEMP}/bin
rm vale.tar.gz
Expand All @@ -83,7 +92,12 @@ runs:
shell: bash
run: |
echo "::group::Reviewdog Installation"
curl -sL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b ${RUNNER_TEMP}/bin
reviewdogScript=$(curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh)
if [[ "$reviewdogScript" = "" ]]; then
echo "::error title=Reviewdog Download failed::Downloading the Reviewdog script from GitHub failed."
exit 1
fi
printf "$reviewdogScript" | sh -s -- -b ${RUNNER_TEMP}/bin
echo "::endgroup::"
- name: 🧑‍🏫 Run Vale with Reviewdog
Expand Down

0 comments on commit 6b31f21

Please sign in to comment.