Skip to content

Commit

Permalink
Fix action.sh indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
socheatsok78 committed May 2, 2024
1 parent a88f802 commit 7666307
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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..."
Expand All @@ -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:"
Expand Down

0 comments on commit 7666307

Please sign in to comment.