Files
runner-images/images/macos/provision/core/toolcache.sh
Mikhail Timofeev 0d46520ccf [macOS] Fail builds on errors during the image generation (#1756)
* set -e and fix all the scripts

* add source utils to finalize_vm script

* change xcode version in postbuild script

* fix for softwareupdates and for xcode version
2020-10-23 17:59:08 +03:00

38 lines
1.2 KiB
Bash
Executable File

#!/bin/bash -e -o pipefail
# Download hosted tool cache with npm
NPM_FEED="npm.pkg.github.com"
TOOLSET_PATH="$HOME/image-generation/toolcache.json"
echo "Installing npm-toolcache..."
PACKAGE_LIST=($(jq -r 'keys | .[]' $TOOLSET_PATH))
# Execute in /tmp folder to avoid node_modules creation in $HOME
pushd /tmp
# GitHub Package Registry doesn't support downloading public packages without auth so we have to authorize
# Put the .npmrc to /tmp directory on the image to make sure that it will deleted after image generation
echo "Configure auth for github package registry"
echo "@actions:registry=https://${NPM_FEED}/" >> ".npmrc"
echo "//${NPM_FEED}/:_authToken=${GITHUB_FEED_TOKEN}" >> ".npmrc"
echo "Install packages..."
for PACKAGE_NAME in ${PACKAGE_LIST[@]}; do
PACKAGE_VERSIONS=($(jq -r ".[\"$PACKAGE_NAME\"] | .[]" $TOOLSET_PATH))
for PACKAGE_VERSION in ${PACKAGE_VERSIONS[@]}; do
echo "Install ${PACKAGE_NAME}@${PACKAGE_VERSION}"
npm install ${PACKAGE_NAME}@${PACKAGE_VERSION}
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "${PACKAGE_NAME}@${PACKAGE_VERSION} installation failure; Error:${exit_code}"
exit 1
fi
done;
done;
rm -f ".npmrc"
popd