Created
September 28, 2019 18:26
-
-
Save mhart/181a8334ab217a1d55dc37aa27442095 to your computer and use it in GitHub Desktop.
Simple module caching script, for CI or similar
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 -ex | |
# Tries to download latest cached node_modules based on package-lock.json | |
# If it can't, then `npm ci` and push up node_modules to cache | |
# Assumes S3_BUCKET env var has been set, and that `aws` credentials | |
# are configured (either in env, or ~/.aws/credentials) | |
CHECKSUM=$(sha256sum package-lock.json | awk '{print $1}') | |
if ! aws s3 cp s3://${S3_BUCKET}/cache/${CHECKSUM}.tgz - | tar -xz; then | |
npm ci | |
tar -cz node_modules | aws s3 cp - s3://${S3_BUCKET}/cache/${CHECKSUM}.tgz | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Swap out
aws s3
forgsutil cp
on Google Cloud orazcopy
on Azure