diff --git a/Jenkinsfile b/Jenkinsfile index 2d58fbd748f2fc0172b6592e50dfae6abffad288..2b1406ec35f06b983cc0763f3a8a8c6eabf2e42f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,9 +34,15 @@ pipeline { def baseAssetsPath = "https://assets-dev.reticium.io/" def assetBundleServer = "https://assets-bundles-dev.reticium.io/" def s3Destination = "s3://assets.reticulum-dev-7f8d39c45878ee2e/hubs" - def habCommand = "sudo /usr/bin/hab-docker-studio -k mozillareality run /bin/bash scripts/hab-build-and-push.sh ${baseAssetsPath} ${assetBundleServer} ${s3Destination}" + def s3AssetsDestination = "${s3Destination}/assets" + def s3PagesDestination = "${s3Destination}/pages" + + def habCommand = "sudo /usr/bin/hab-docker-studio -k mozillareality run /bin/bash scripts/hab-build-and-push.sh ${baseAssetsPath} ${assetBundleServer}" sh "/usr/bin/script --return -c ${shellString(habCommand)} /dev/null" + + sh "aws s3 sync --acl public-read --cache-control max-age=31556926 build/assets $(shellString(s3AssetsDestination))" + sh "aws s3 sync --acl public-read --cache-control no-cache --delete build/pages $(shellString(s3PagesDestination))" } } } diff --git a/scripts/hab-build-and-push.sh b/scripts/hab-build-and-push.sh index dab548add9df29e6653f7002237c152326caeb49..672d70a43b9323038f4c31bb2464c2427d90d40c 100755 --- a/scripts/hab-build-and-push.sh +++ b/scripts/hab-build-and-push.sh @@ -2,7 +2,6 @@ export BASE_ASSETS_PATH=$1 export ASSET_BUNDLE_SERVER=$2 -export TARGET_S3_PATH=$3 # To build + push to S3 run: # hab studio run "bash scripts/hab-build-and-push.sh" @@ -10,13 +9,9 @@ export TARGET_S3_PATH=$3 # On exit, need to make all files writable so CI can clean on next build trap 'chmod -R a+rw .' EXIT -echo "Started build in $(pwd)" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" pushd "$DIR/.." -echo "Building in $(pwd)" - -ls mkdir -p .yarn mkdir -p node_modules @@ -28,16 +23,9 @@ mkdir -p /usr/local/share rm /usr/bin/env ln -s "$(hab pkg path core/coreutils)/bin/env" /usr/bin/env -hab pkg install -b core/coreutils core/bash core/node core/yarn core/aws-cli core/git +hab pkg install -b core/coreutils core/bash core/node core/yarn core/git yarn install --cache-folder .yarn -ls node_modules -ls node_modules/.bin GENERATE_SMOKE_TESTS=true yarn build --output-path build mkdir build/pages mv build/*.html build/pages - -aws s3 sync --acl public-read --cache-control "max-age=31556926" build/assets "$TARGET_S3_PATH/assets" -aws s3 sync --acl public-read --cache-control "no-cache" --delete build/pages "$TARGET_S3_PATH/pages" - -rm -rf build