Created
July 26, 2018 00:07
-
-
Save MateuszKubuszok/6e6cb24eb4d81ace2d570f70ab8644b4 to your computer and use it in GitHub Desktop.
Publishing and testing Jekyll sites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash --login | |
ThisDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
cd "$ThisDir/.." | |
if [ ! `command -v jekyll > /dev/null` ]; then | |
rvm use default ruby | |
bundle install | |
fi | |
JEKYLL_ENV=production bundle exec jekyll build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export AWS_ACCESS_KEY_ID="[access key]" | |
export AWS_SECRET_ACCESS_KEY="[secret]" | |
export AWS_DEFAULT_REGION="[S3 region]" | |
export BUCKET="[S3 bucket]" | |
export CF_DISTRIBUTION_ID="[CF]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash --login | |
ThisDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
source "$ThisDir/config.sh" | |
if grep "http://localhost:4000" "$ThisDir/../_site/feed.xml" > /dev/null; then | |
echo Publish should be run after build.sh not serve.sh | |
echo -- preventing publishing developer version -- | |
exit 1 | |
fi | |
pushd $ThisDir/../_site/ > /dev/null | |
aws s3 sync --delete --size-only --no-progress --sse AES256 ./ s3://$BUCKET/ \ | |
| sed 's/^(dryrun) //' \ | |
| awk '{print "/"$2;}' \ | |
| sed 's/\/.\//\//' \ | |
| sed 's/index.html$//' \ | |
| xargs --no-run-if-empty aws cloudfront create-invalidation --distribution-id $CF_DISTRIBUTION_ID --paths | |
popd > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash --login | |
ThisDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
cd "$ThisDir/.." | |
if [ ! `command -v jekyll > /dev/null` ]; then | |
rvm use default ruby | |
bundle install | |
fi | |
bundle exec jekyll serve --incrementa --draft --verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements
I set up CF mostly for free SSL certificate, so if you don't need it you might just remove the invalidation from the script.
Installation:
deployment
directory.chmod +x
them.config.sh
- do not commit it! Adddeployment/config.sh
file to.gitignore
.'deployment'
toexclude
in_config.yml
.Usage:
./deployment/serve.sh
- test site locally./deployment/build.sh && ./deployment/publish.sh
- build production version and publish it to S3 with invalidations.