Skip to content

Instantly share code, notes, and snippets.

@sarahbohr
Created May 4, 2018 17:42
Show Gist options
  • Save sarahbohr/26f47525769c3927cb8a158e7827f29d to your computer and use it in GitHub Desktop.
Save sarahbohr/26f47525769c3927cb8a158e7827f29d to your computer and use it in GitHub Desktop.
Deploy a static site on AWS with awscli
brew install python
brew install pip
sudo pip install awscli
aws configure
AWS Access Key ID [None]: XXXXXXXXXXXXX
AWS Secret Access Key [None]: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Default region name [None]:
Default output format [None]:
aws configure set preview.cloudfront true
#!/bin/bash
CURR_COMMIT=$(git rev-parse HEAD);
CURR_VERSION=$(node -e "console.log(require('./package.json').version);");
VER_HASH=$(git rev-list -n 1 v$CURR_VERSION);
# Don't want to redo version bump
if [ $CURR_COMMIT == $VER_HASH ]
then
echo 'Already up to date'
exit
fi
npm version patch;
NEW_VERSION=$(node -e "console.log(require('./package.json').version);");
echo $NEW_VERSION;
git push origin head;
npm run buildprod
aws s3 sync ./public s3://YOUR_S3_BUCKET_NAME --size-only --delete;
# Invalidate cache
aws cloudfront create-invalidation \
--distribution-id YOUR_DISTRIBUTION_ID \
--paths "/*";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment