diff --git a/action.sh b/action.sh index 8603fb9..c67325f 100755 --- a/action.sh +++ b/action.sh @@ -10,8 +10,8 @@ INPUT_PREFIX=${4:-"false"} INPUT_LIMIT=${5:-"3"} if [[ -z "${INPUT_REPOSITORY}" ]]; then - echo "::error::Missing required 'repository' input" - exit 1 + echo "::error::Missing required 'repository' input" + exit 1 fi # Private variables @@ -20,9 +20,9 @@ X_GITHUB_RELEASE_API_URL="/repos/${INPUT_REPOSITORY}/releases" X_JQ_RELEASE_QUERY="{tag_name, target_commitish, author: .author.login, created_at, published_at}" if [[ "$INPUT_RELEASE" == "latest" ]]; then - X_GITHUB_RELEASE_API_URL="${X_GITHUB_RELEASE_API_URL}/latest" + X_GITHUB_RELEASE_API_URL="${X_GITHUB_RELEASE_API_URL}/latest" else - X_JQ_RELEASE_QUERY=".[] | ${X_JQ_RELEASE_QUERY}" + X_JQ_RELEASE_QUERY=".[] | ${X_JQ_RELEASE_QUERY}" fi echo "Querying GitHub releases for \"$INPUT_REPOSITORY\" repository..." @@ -36,19 +36,19 @@ mkdir -p "$RUNNER_TEMP/$INPUT_REPOSITORY" GITHUB_RELEASE_MATRIX_ACTION_RAW_RELEASE_FILE="$RUNNER_TEMP/$INPUT_REPOSITORY/releases.json" GITHUB_RELEASE_MATRIX_ACTION_RELEASE_FILE="$RUNNER_TEMP/$INPUT_REPOSITORY/releases-filtered.json" gh api \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: ${X_GITHUB_API_VERSION}" \ - "$X_GITHUB_RELEASE_API_URL" \ - > "$GITHUB_RELEASE_MATRIX_ACTION_RAW_RELEASE_FILE" + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: ${X_GITHUB_API_VERSION}" \ + "$X_GITHUB_RELEASE_API_URL" \ + > "$GITHUB_RELEASE_MATRIX_ACTION_RAW_RELEASE_FILE" cat "$GITHUB_RELEASE_MATRIX_ACTION_RAW_RELEASE_FILE" | - jq --raw-output "if \"$INPUT_RELEASE\" == \"*\" then map(select(.draft == false and .prerelease == $INPUT_PRERELEASE)) else . end" | - jq --raw-output "$X_JQ_RELEASE_QUERY" | - jq --raw-output "if ($INPUT_PREFIX) then .tag_name |= ltrimstr(\"v\") else . end" | - jq --raw-output --slurp "." | - jq --raw-output "if $INPUT_LIMIT < 0 then . else .[:$INPUT_LIMIT] end" | - jq --raw-output "tostring" \ - > "$GITHUB_RELEASE_MATRIX_ACTION_RELEASE_FILE" + jq --raw-output "if \"$INPUT_RELEASE\" == \"*\" then map(select(.draft == false and .prerelease == $INPUT_PRERELEASE)) else . end" | + jq --raw-output "$X_JQ_RELEASE_QUERY" | + jq --raw-output "if ($INPUT_PREFIX) then .tag_name |= ltrimstr(\"v\") else . end" | + jq --raw-output --slurp "." | + jq --raw-output "if $INPUT_LIMIT < 0 then . else .[:$INPUT_LIMIT] end" | + jq --raw-output "tostring" \ + > "$GITHUB_RELEASE_MATRIX_ACTION_RELEASE_FILE" echo "" echo "Exporting environment variables:"