angular-cn/aio/scripts/deploy-preview.sh
Georgios Kalpakas d0bc83ca27 build(aio): implement prerendering
The current implementation is based on @igorminar's [angular-io-v42][1]. It is
using Protractor to request all docs URLs, let them fallback to `/index.html`
and save the rendered page.

[1]: https://github.com/IgorMinar/angular-io-v42/tree/05508ab3/tools/prerenderer

Fixes #15104
2017-03-17 15:31:22 -05:00

33 lines
825 B
Bash
Executable File

#!/usr/bin/env bash
# WARNING: NGBUILDS_IO_KEY should NOT be printed.
set +x -eu -o pipefail
INPUT_DIR=dist/
OUTPUT_FILE=/tmp/snapshot.tar.gz
AIO_BUILDS_HOST=https://ngbuilds.io
UPLOAD_URL=$AIO_BUILDS_HOST/create-build/$TRAVIS_PULL_REQUEST/$TRAVIS_PULL_REQUEST_SHA
cd "`dirname $0`/.."
# Assumes the build step has already run
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
exec 3>&1
httpCode=$(
curl --include --location --request POST --silent --write-out "\nHTTP_CODE: %{http_code}\n" \
--header "Authorization: Token $NGBUILDS_IO_KEY" --data-binary "@$OUTPUT_FILE" "$UPLOAD_URL" \
| sed 's/\r\n/\n/' \
| tee /dev/fd/3 \
| tail -1 \
| sed 's/HTTP_CODE: //'
)
# Exit with an error if the request failed
if [ $httpCode -lt 200 ] || [ $httpCode -ge 400 ]; then
exit 1
fi
cd -