Skip to content

Instantly share code, notes, and snippets.

@levnovikov
Created November 15, 2022 01:41
Show Gist options
  • Save levnovikov/4ba51520d31d57315df4f5b185d68446 to your computer and use it in GitHub Desktop.
Save levnovikov/4ba51520d31d57315df4f5b185d68446 to your computer and use it in GitHub Desktop.
# Build the markdown files and output
# (verbosely) information about the
# process.
hugo -v
# Send the new files to the configured S3
# (and delete the old ones that are not in
# the new desired state) with a special
# max-age header configuration so that both
# browsers and CDNs cache it for some time.
aws s3 sync \
--delete \
--cache-control max-age=10800 \
./public/ s3://$BUCKET
# Create a new invalidation that will simply
# invalidate any objects that we have in our
# website bucket such that we serve fresh content
# to the users that are requests files from the
# edge locations
#
# ps.: users that already downloaded our
# resources will still have then until
# the browser cache gets invalidated
aws cloudfront \
create-invalidation \
--distribution-id $DISTRIBUTION_ID \
--paths '/*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment