ci(aio): fail the build if preview deployment fails
This commit is contained in:
parent
5ab2e28703
commit
e40f81b564
|
@ -28,3 +28,5 @@
|
||||||
- Do we care to keep logs (e.g. cron, nginx, aio-upload-server, aio-clean-up, pm2) outside of the container?
|
- Do we care to keep logs (e.g. cron, nginx, aio-upload-server, aio-clean-up, pm2) outside of the container?
|
||||||
- Instead of creating new comments for each commit, update the original comment?
|
- Instead of creating new comments for each commit, update the original comment?
|
||||||
- Do we want to drop HTTP support (and/or redirect to HTTPS)?
|
- Do we want to drop HTTP support (and/or redirect to HTTPS)?
|
||||||
|
- When re-running a Travis job build that has previous succeeded for AIO, it will not be able to
|
||||||
|
deploy and fail.
|
||||||
|
|
|
@ -6,10 +6,26 @@ set -eux -o pipefail
|
||||||
INPUT_DIR=dist/
|
INPUT_DIR=dist/
|
||||||
OUTPUT_FILE=/tmp/snapshot.tar.gz
|
OUTPUT_FILE=/tmp/snapshot.tar.gz
|
||||||
AIO_BUILDS_HOST=https://ngbuilds.io
|
AIO_BUILDS_HOST=https://ngbuilds.io
|
||||||
|
UPLOAD_URL=$AIO_BUILDS_HOST/create-build/$TRAVIS_PULL_REQUEST/$TRAVIS_PULL_REQUEST_SHA
|
||||||
|
|
||||||
cd "`dirname $0`/.."
|
cd "`dirname $0`/.."
|
||||||
|
|
||||||
yarn run build -- --prod
|
yarn run build -- --prod
|
||||||
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
|
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
|
||||||
curl -iLX POST --header "Authorization: Token $NGBUILDS_IO_KEY" --data-binary "@$OUTPUT_FILE" \
|
|
||||||
"$AIO_BUILDS_HOST/create-build/$TRAVIS_PULL_REQUEST/$TRAVIS_COMMIT"
|
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 -
|
cd -
|
||||||
|
|
Loading…
Reference in New Issue