Skip to content

Commit a904c9a

Browse files
authored
Merge pull request #50 from bitovi/fix/bucket-name-check
Fix wrong path used for check bucket name script
2 parents 4d5e43d + 98c31b1 commit a904c9a

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

operations/_scripts/deploy/deploy.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
#!/bin/bash
2-
set -x
2+
set -e -o pipefail
33

44
echo "In deploy.sh"
55
GITHUB_REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
66

77
# Generate buckets identifiers and check them agains AWS Rules
88
export TF_STATE_BUCKET="$(/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/generate/generate_buckets_identifiers.sh tf | xargs)"
9-
/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/deploy/check_bucket_name.sh $TF_STATE_BUCKET
10-
export LB_LOGS_BUCKET="$(/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/generate/generate_buckets_identifiers.sh lb | xargs)"
11-
/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/deploy/check_bucket_name.sh $LB_LOGS_BUCKET
12-
13-
# Generate buckets identifiers
14-
export TF_STATE_BUCKET="$(/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/generate/generate_buckets_identifiers.sh tf | xargs)"
9+
/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/generate/check_bucket_name.sh $TF_STATE_BUCKET
1510
export LB_LOGS_BUCKET="$(/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/generate/generate_buckets_identifiers.sh lb | xargs)"
11+
/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/generate/check_bucket_name.sh $LB_LOGS_BUCKET
1612

1713
# Generate subdomain
1814
/bin/bash $GITHUB_ACTION_PATH/operations/_scripts/generate/generate_subdomain.sh

operations/_scripts/generate/check_bucket_name.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,49 @@ set -e
99
function checkBucket() {
1010
# check length of bucket name
1111
if [[ ${#1} -lt 3 || ${#1} -gt 63 ]]; then
12-
echo "::error::Bucket name must be between 3 and 63 characters long."
12+
echo "::error::Bucket name '$1' must be between 3 and 63 characters long."
1313
exit 1
1414
fi
1515

1616
# check that bucket name consists only of lowercase letters, numbers, dots (.), and hyphens (-)
1717
if [[ ! $1 =~ ^[a-z0-9.-]+$ ]]; then
18-
echo "::error::Bucket name can only consist of lowercase letters, numbers, dots (.), and hyphens (-)."
18+
echo "::error::Bucket name '$1' can only consist of lowercase letters, numbers, dots (.), and hyphens (-)."
1919
exit 1
2020
fi
2121

2222
# check that bucket name begins and ends with a letter or number
2323
if [[ ! $1 =~ ^[a-zA-Z0-9] ]]; then
24-
echo "::error::Bucket name must begin with a letter or number."
24+
echo "::error::Bucket name '$1' must begin with a letter or number."
2525
exit 1
2626
fi
2727
if [[ ! $1 =~ [a-zA-Z0-9]$ ]]; then
28-
echo "::error::Bucket name must end with a letter or number."
28+
echo "::error::Bucket name '$1' must end with a letter or number."
2929
exit 1
3030
fi
3131

3232
# check that bucket name does not contain two adjacent periods
3333
if [[ $1 =~ \.\. ]]; then
34-
echo "::error::Bucket name cannot contain two adjacent periods."
34+
echo "::error::Bucket name '$1' cannot contain two adjacent periods."
3535
exit 1
3636
fi
3737

3838
# check that bucket name is not formatted as an IP address
3939
if [[ $1 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
40-
echo "::error::Bucket name cannot be formatted as an IP address."
40+
echo "::error::Bucket name '$1' cannot be formatted as an IP address."
4141
exit 1
4242
fi
4343

4444
# check that bucket name does not start with the prefix xn--
4545
if [[ $1 =~ ^xn-- ]]; then
46-
echo "::error::Bucket name cannot start with the prefix xn--."
46+
echo "::error::Bucket name '$1' cannot start with the prefix xn--."
4747
exit 1
4848
fi
4949

5050
# check that bucket name does not end with the suffix -s3alias
5151
if [[ $1 =~ -s3alias$ ]]; then
52-
echo "::error::Bucket name cannot end with the suffix -s3alias."
52+
echo "::error::Bucket name '$1' cannot end with the suffix -s3alias."
5353
exit 1
5454
fi
5555
}
5656

57-
checkBucket $1
57+
checkBucket $1

operations/_scripts/generate/generate_buckets_identifiers.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

3-
set -e
3+
set -eo pipefail
44

5-
GITHUB_IDENTIFIER="$(echo $($GITHUB_ACTION_PATH/operations/_scripts/generate/generate_identifier.sh) | tr '[:upper:]' '[:lower:]' | tr '_' '-' )"
5+
GITHUB_IDENTIFIER="$(echo $($GITHUB_ACTION_PATH/operations/_scripts/generate/generate_identifier.sh) | tr '[:upper:]' '[:lower:]' | tr '_' '-' | tr '/' '.' )"
66

77
case $1 in
88
tf)
@@ -28,4 +28,4 @@ case $1 in
2828
fi
2929
echo "$LB_LOGS_BUCKET"
3030
;;
31-
esac
31+
esac

0 commit comments

Comments
 (0)