-
Notifications
You must be signed in to change notification settings - Fork 5
/
publish
executable file
·38 lines (32 loc) · 1.08 KB
/
publish
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
set -euo pipefail
base="$(dirname $0)"
echo "-> Finding CloudFront distribution"
distribution=$(
aws cloudfront list-distributions \
--query 'DistributionList.Items[?contains(Aliases.Items, `data.nextstrain.org`)] | [0].Id' \
--output text
)
if [[ -z $distribution || $distribution == None ]]; then
echo "Unable to find CloudFront distribution id for data.nextstrain.org" >&2
echo
echo "Are your AWS CLI credentials for the right account?" >&2
exit 1
fi
echo "-> Uploading to S3"
aws s3 cp --content-type text/yaml \
"$base"/nextstrain.yml \
s3://nextstrain-data/
echo "-> Creating CloudFront invalidation for distribution $distribution"
invalidation=$(
aws cloudfront create-invalidation \
--distribution-id "$distribution" \
--paths /nextstrain.yml \
--query Invalidation.Id \
--output text
)
echo "-> Waiting for CloudFront invalidation $invalidation to complete"
echo " Ctrl-C to stop waiting."
aws cloudfront wait invalidation-completed \
--distribution-id "$distribution" \
--id "$invalidation"