2017-02-06 13:40:28 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-03-05 09:32:44 -05:00
|
|
|
# WARNING: NGBUILDS_IO_KEY should NOT be printed.
|
|
|
|
set +x -eu -o pipefail
|
2017-02-06 13:40:28 -05:00
|
|
|
|
|
|
|
|
|
|
|
INPUT_DIR=dist/
|
|
|
|
OUTPUT_FILE=/tmp/snapshot.tar.gz
|
|
|
|
AIO_BUILDS_HOST=https://ngbuilds.io
|
2017-03-02 18:58:31 -05:00
|
|
|
UPLOAD_URL=$AIO_BUILDS_HOST/create-build/$TRAVIS_PULL_REQUEST/$TRAVIS_PULL_REQUEST_SHA
|
2017-02-06 13:40:28 -05:00
|
|
|
|
|
|
|
cd "`dirname $0`/.."
|
2017-03-02 18:58:31 -05:00
|
|
|
|
2017-03-08 09:26:51 -05:00
|
|
|
yarn run build
|
2017-02-06 13:40:28 -05:00
|
|
|
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
|
2017-03-02 18:58:31 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-02-06 13:40:28 -05:00
|
|
|
cd -
|