Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 679e202

Browse files
committed
Add option to deploy to public buckets. Add clobber option to configure-deploy
1 parent e1a1cc6 commit 679e202

File tree

4 files changed

+87
-7
lines changed

4 files changed

+87
-7
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ script:
2424
before_deploy:
2525

2626
- pip install awscli --upgrade
27-
- bash _scripts/configure-deploy.sh
27+
- bash _scripts/configure-deploy.sh --clobber
2828

2929
deploy:
3030
- provider: script
31-
script: bash _scripts/deploy.sh --verbose production
31+
script: bash _scripts/deploy.sh --public --verbose production
3232
skip_cleanup: true
3333
on:
3434
repo: aws-samples/aws-genomics-workflows
3535
branch: release
3636
tags: true
3737
- provider: script
38-
script: bash _scripts/deploy.sh --verbose test
38+
script: bash _scripts/deploy.sh --public --verbose test
3939
skip_cleanup: true
4040
on:
4141
repo: aws-samples/aws-genomics-workflows

_scripts/configure-deploy.sh

100644100755
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,60 @@
11
#!/bin/bash
22

3+
# Create a default ~/.aws/configure file for Travis testing
4+
35
set -e
46

57
# This script expects the following environment variable(s)
68
# ASSET_ROLE_ARN: the AWS role ARN that is used to publish assets
79

10+
usage() {
11+
cat <<EOM
12+
Usage:
13+
$(basename $0) [--clobber]
14+
15+
--clobber Overwrite ~/.aws/configure file without asking
16+
EOM
17+
}
18+
19+
CLOBBER=''
20+
PARAMS=""
21+
while (( "$#" )); do
22+
case "$1" in
23+
--clobber)
24+
CLOBBER=1
25+
shift
26+
;;
27+
--help)
28+
usage
29+
exit 0
30+
;;
31+
--) # end optional argument parsing
32+
shift
33+
break
34+
;;
35+
-*|--*=)
36+
echo "Error: unsupported argument $1" >&2
37+
exit 1
38+
;;
39+
*) # positional agruments
40+
PARAMS="$PARAMS $1"
41+
shift
42+
;;
43+
esac
44+
done
45+
eval set -- "$PARAMS"
46+
47+
if [ -z $CLOBBER ]; then
48+
while true; do
49+
read -p "Overwrite ~/.aws/config file [y/n]? " yn
50+
case $yn in
51+
[Yy]* ) CLOBBER=1; break;;
52+
[Nn]* ) echo "Exiting"; exit;;
53+
* ) echo "Please answer yes or no.";;
54+
esac
55+
done
56+
fi
57+
858
mkdir -p $HOME/.aws
959
cat << EOF > $HOME/.aws/config
1060
[default]

_scripts/deploy.sh

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ ASSET_STAGE=test
1010
ASSET_PROFILE=asset-publisher
1111
DEPLOY_REGION=us-east-1
1212

13+
usage() {
14+
cat <<EOM
15+
Usage:
16+
$(basename $0) [--site-bucket BUCKET] [--asset-bucket BUCKET] [--asset-profile PROFILE] [--deploy-region REGION] [--public] [--verbose]
17+
18+
--site-bucket BUCKET Deploy documentation site to BUCKET
19+
--asset-bucket BUCKET Deploy assets to BUCKET
20+
--asset-profile PROFILE Use PROFILE for AWS CLI commands
21+
--deploy-region REGION Deploy in region REGION
22+
--public Deploy to public bucket with '--acl public-read' (Default false)
23+
--verbose Display more output
24+
EOM
25+
}
26+
27+
ACL_PUBLIC_READ=''
1328
VERBOSE=''
1429
PARAMS=""
1530
while (( "$#" )); do
@@ -30,6 +45,14 @@ while (( "$#" )); do
3045
DEPLOY_REGION=$2
3146
shift 2
3247
;;
48+
--help)
49+
usage
50+
exit 0
51+
;;
52+
--public)
53+
ACL_PUBLIC_READ='--acl public-read'
54+
shift
55+
;;
3356
--verbose)
3457
VERBOSE='--verbose'
3558
shift
@@ -77,7 +100,7 @@ function s3_sync() {
77100
cmd="aws s3 sync \
78101
--profile $ASSET_PROFILE \
79102
--region $DEPLOY_REGION \
80-
--acl public-read \
103+
$ACL_PUBLIC_READ \
81104
--delete \
82105
--metadata commit=$(git rev-parse HEAD) \
83106
$source \
@@ -164,12 +187,14 @@ function site() {
164187
echo "requirement mkdocs not found. aborting"
165188
exit 1
166189
fi
167-
mkdocs build
190+
[ -z $VERBOSE ] && QUIET='-q' || QUIET=''
191+
mkdocs build $QUIET
168192

169193
echo "publishing site"
170194
aws s3 sync \
195+
--profile $ASSET_PROFILE \
171196
--region $DEPLOY_REGION \
172-
--acl public-read \
197+
$ACL_PUBLIC_READ \
173198
--delete \
174199
--metadata commit=$(git rev-parse HEAD) \
175200
./site \

_scripts/make-dist.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ done
9292
echo "packaging amazon-ebs-autoscale"
9393
cd $TEMP_PATH
9494

95-
EBS_AUTOSCALE_VERSION=$(curl --silent "https://api.github.com/repos/awslabs/amazon-ebs-autoscale/releases/latest" | jq -r .tag_name)
95+
RESPONSE=$(curl --silent "https://api.github.com/repos/awslabs/amazon-ebs-autoscale/releases/latest")
96+
EBS_AUTOSCALE_VERSION=$(echo $RESPONSE | jq -r .tag_name)
97+
if [[ $EBS_AUTOSCALE_VERSION = 'null' ]]; then
98+
echo "ERROR: $RESPONSE"
99+
exit 1
100+
fi
96101
curl --silent -L \
97102
"https://github.com/awslabs/amazon-ebs-autoscale/archive/${EBS_AUTOSCALE_VERSION}.tar.gz" \
98103
-o ./amazon-ebs-autoscale.tar.gz

0 commit comments

Comments
 (0)