-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.sh
62 lines (46 loc) · 1.23 KB
/
script.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash -l
set -e
# check configuration
err=0
build_path=$1
bucket_name=$2
bucket_key=$3
distribution_invalidation_path=$4
empty_bucket=$5
aws_region=AWS_REGION
ls -l $build_path
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
echo "AWS_ACCESS_KEY_ID was not found. Set this in your github secrets"
err=1
fi
if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
echo "AWS_SECRET_ACCESS_KEY was not found. Set this in your github secrets"
err=1
fi
if [ -z "$aws_region" ]; then
echo "Specify an AWS region"
err=1
fi
if [ -z "$bucket_name" ]; then
echo "Specify a bucket you will like to deploy to"
err=1
fi
if [ $err -eq 1 ]; then
exit 1
fi
output="AWS OUTPUT"
echo "::set-output name=aws-deploy-output::$output"
if [ "$empty_bucket" == "true" ]; then
aws s3 rm s3://$bucket_name/$bucket_key --recursive
fi
aws s3 cp $build_path s3://$bucket_name/$bucket_key --recursive
if [ -z "$DISTRIBUTION_ID" ]; then
echo "Skipping cloudfront invalidation..."
else
if [ -z "$distribution_invalidation_path" ]; then
echo "Specify the invalidation path. e.g. /* or /production/*"
exit 1
fi
echo "Invalidating cloudfront..."
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths "$distribution_invalidation_path"
fi