diff --git a/Jenkinsfile b/Jenkinsfile index ef75d120c0fd95c20dfa4fd2df24db385d318171..9429b09471ae06fbd11ea33b775e97b6380cf8ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,7 +34,11 @@ pipeline { steps { script { def baseAssetsPath = "https://assets-dev.reticium.io/" - sh "GENERATE_SMOKE_TEST=true BASE_ASSETS_PATH=${shellString(baseAssetsPath)} yarn build -- --output-path build" + def s3Destination = "s3://assets.reticulum-dev-7f8d39c45878ee2e/hubs" + + sh ''' + /usr/bin/script --return -c \\\\"sudo /usr/bin/hab-docker-studio -k mozillareality run /bin/bash scripts/hab-build-and-push.sh ${shellString(baseAssetsPath)} ${shellString(s3Destination)}\\\\" /dev/null + ''' } } } diff --git a/scripts/hab-build-and-push.sh b/scripts/hab-build-and-push.sh new file mode 100644 index 0000000000000000000000000000000000000000..79de8880c6ab735fffc2dc37c6ef56275bcd2bc8 --- /dev/null +++ b/scripts/hab-build-and-push.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +BASE_ASSETS_PATH=$1 +TARGET_S3_PATH=$2 + +# To build + push to S3 run: +# hab studio run "bash scripts/hab-build-and-push.sh" + +# On exit, need to make all files writable so CI can clean on next build +trap 'chmod -R a+rw .' EXIT + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +pushd "$DIR/.." + +mkdir -p .yarn +mkdir -p node_modules +mkdir -p build + +# Yarn expects /usr/local/share +# https://github.com/yarnpkg/yarn/issues/4628 +mkdir -p /usr/local/share + +[[ ! -f /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 + +yarn install --cache-folder .yarn +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