ci(aio): create previews for all PRs that touch non-spec files in aio/
or packages/
(#16733)
Previously, no previews would be deployed for PRs that didn't touch files inside `aio/`. Now, previews will be deployed for PRs that touch non-spec files inside either `aio/` or `packages/` (as long as other preconditions are met). Partially addresses #16526.
This commit is contained in:

committed by
Igor Minar

parent
44c7ac0fe9
commit
decb4cc4a3
@ -4,21 +4,53 @@
|
||||
set +x -eu -o pipefail
|
||||
|
||||
|
||||
INPUT_DIR=dist/
|
||||
OUTPUT_FILE=/tmp/snapshot.tar.gz
|
||||
AIO_BUILDS_DOMAIN=ngbuilds.io
|
||||
UPLOAD_URL=https://$AIO_BUILDS_DOMAIN/create-build/$TRAVIS_PULL_REQUEST/$TRAVIS_PULL_REQUEST_SHA
|
||||
DEPLOYED_URL=https://pr$TRAVIS_PULL_REQUEST-$TRAVIS_PULL_REQUEST_SHA.$AIO_BUILDS_DOMAIN
|
||||
readonly INPUT_DIR=dist/
|
||||
readonly OUTPUT_FILE=/tmp/snapshot.tar.gz
|
||||
readonly AIO_BUILDS_DOMAIN=ngbuilds.io
|
||||
readonly UPLOAD_URL=https://$AIO_BUILDS_DOMAIN/create-build/$TRAVIS_PULL_REQUEST/$TRAVIS_PULL_REQUEST_SHA
|
||||
readonly DEPLOYED_URL=https://pr$TRAVIS_PULL_REQUEST-$TRAVIS_PULL_REQUEST_SHA.$AIO_BUILDS_DOMAIN
|
||||
readonly skipBuild=$([[ "$1" == "--skip-build" ]] && echo "true" || echo "");
|
||||
readonly relevantChangedFilesCount=$(git diff --name-only $TRAVIS_COMMIT_RANGE | grep -P "^(?:aio|packages)/(?!.*[._]spec\.[jt]s$)" | wc -l)
|
||||
|
||||
cd "`dirname $0`/.."
|
||||
|
||||
# Do not deploy unless this PR has touched relevant files: `aio/` or `packages/` (except for spec files)
|
||||
if [[ $relevantChangedFilesCount -eq 0 ]]; then
|
||||
echo "Skipping deploy because this PR did not touch any relevant files."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Do not deploy unless this PR meets certain preconditions.
|
||||
readonly preverifyExitCode=$(./aio-builds-setup/scripts/travis-preverify-pr.sh && echo 0 || echo $?)
|
||||
case $preverifyExitCode in
|
||||
0)
|
||||
# Preconditions met: Deploy
|
||||
;;
|
||||
1)
|
||||
# Preconditions not met: Skip deploy
|
||||
echo "Skipping deploy because this PR did not meet the preconditions."
|
||||
exit 0
|
||||
;;
|
||||
2)
|
||||
# An error occurred: Fail the script
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
# Unexpected exit code: Fail the script
|
||||
echo "Unexpected preverification exit code: $preverifyExitCode"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Build the app
|
||||
yarn build
|
||||
if [ "$skipBuild" != "true" ]; then
|
||||
yarn build
|
||||
fi
|
||||
tar --create --gzip --directory "$INPUT_DIR" --file "$OUTPUT_FILE" .
|
||||
|
||||
# Deploy to staging
|
||||
exec 3>&1
|
||||
httpCode=$(
|
||||
readonly 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/' \
|
||||
|
Reference in New Issue
Block a user