Skip to content

Commit

Permalink
Improve error output by using GitHub Action workflow commands
Browse files Browse the repository at this point in the history
  • Loading branch information
nkuik committed Dec 21, 2022
1 parent 96a954a commit fa0cf2e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
required: false
description: |
Directory to run the action on, from the repo root.
Default is . ( root of the repository)
Default is . (root of the repository)
default: "."
version:
required: false
Expand All @@ -20,7 +20,7 @@ inputs:
additional_args:
required: false
description: |
Space seperated args specified here will be added during tfsec execution.
Space separated args specified here will be added during tfsec execution.
(eg. --force-all-dirs --verbose)
soft_fail:
required: false
Expand Down
11 changes: 5 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -xe

This comment has been minimized.

Copy link
@jonaswmoura

jonaswmoura Oct 3, 2024

@nkuik Is there a reason why debug mode is enabled? This is messing up my workflow output.


if [ -z "${INPUT_GITHUB_TOKEN}" ] ; then
echo "Consider setting a GITHUB_TOKEN to prevent GitHub api rate limits." >&2
echo "::notice title=GitHub API token::Consider setting a GITHUB_TOKEN to prevent GitHub api rate limits"
fi

TFSEC_VERSION=""
Expand All @@ -21,14 +21,13 @@ function get_release_assets() {
--header "Accept: application/vnd.github+json"
)
[ -n "${INPUT_GITHUB_TOKEN}" ] && args+=(--header "Authorization: Bearer ${INPUT_GITHUB_TOKEN}")
api_request="$(curl -sfS "${args[@]}" "https://api.github.com/repos/${repo}/releases/${version}")"

if [[ $? != 0 ]]; then
echo "The request to the GitHub API was likely rate-limited; consider setting a GITHUB_TOKEN to prevent this" >&2
if ! curl --fail-with-body -sS "${args[@]}" "https://api.github.com/repos/${repo}/releases/${version}"; then
echo "::error title=GitHub API request failure::The request to the GitHub API was likely rate-limited. Set a GITHUB_TOKEN to prevent this"
exit 1
else
curl "${args[@]}" "https://api.github.com/repos/${repo}/releases/${version}" | jq '.assets[] | { name: .name, download_url: .browser_download_url }'
fi

echo "${api_request}" | jq '.assets[] | { name: .name, download_url: .browser_download_url }'
}

function install_release() {
Expand Down

0 comments on commit fa0cf2e

Please sign in to comment.