Skip to content

Commit

Permalink
Lint for style
Browse files Browse the repository at this point in the history
I've not bothered saving this patch for reapplication if upstream changes because we had already deviated from that before these changes.

- Use consistent variable syntax
- Prefer `-n` over `! -z`
- Use appropriate quoting for words that have no variable expansion

Signed-off-by: Jack Baldry <[email protected]>
  • Loading branch information
jdbaldry committed Jun 12, 2024
1 parent a9752a3 commit 3659bf0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions actions/aws-auth/resolve-aws-region.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
# https://github.com/catnekaise/cognito-idpool-auth/blob/83ae9e159de469b3acd87ecb361d6b5957ee35ae/action.yml#L192-L227
value=""

if [ ! -z "${AWS_REGION}" ] && [ ! -z "${AWS_DEFAULT_REGION}" ]; then
if [ -n "${AWS_REGION}" ] && [ -n "${AWS_DEFAULT_REGION}" ]; then
value="$AWS_REGION"
fi

if [ -z "$value" ]; then
echo "Unable to resolve what AWS Region to use"
readonly value

if [ -z "${value}" ]; then
echo 'Unable to resolve what AWS region to use'
exit 1
fi

# Some-effort validation of aws region
if echo "$value" | grep -Eqv "^[a-z]{2}-[a-z]{4,9}-[0-9]$"; then
echo "Resolved value for AWS Region is invalid"
if echo "${value}" | grep -Eqv '^[a-z]{2}-[a-z]{4,9}-[0-9]$'; then
echo 'Resolved value for AWS region is invalid'
exit 1
fi

echo "value=$value" >> "$GITHUB_OUTPUT"
echo "AWS_REGION=${AWS_REGION}" >> "$GITHUB_ENV"
echo "AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}" >> "$GITHUB_ENV"
echo "value=${value}" >> "${GITHUB_OUTPUT}"
echo "AWS_REGION=${AWS_REGION}" >> "${GITHUB_ENV}"
echo "AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}" >> "${GITHUB_ENV}"

0 comments on commit 3659bf0

Please sign in to comment.