ci: error handle story book build fail (#52428)

Automatically fail Buildkite build step `:chromatic: Upload Storybook to
Chromatic` if Chromatic storybook build fails.

Previously, if the Chromatic deployment failed to build for some reason,
the build would still succeed. Making the report unreliable

This change adds a check to see if the `pnpm chromatic` exit status is
non zero, and If so, the script will immediately exit with a failure,
causing the Buildkite build to be marked as failed.

context:
https://sourcegraph.slack.com/archives/C04MYFW01NV/p1684969967117259

## Test plan
ci 
<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
This commit is contained in:
Manuel Ucles 2023-05-24 20:29:42 -07:00 committed by GitHub
parent 60d130de3b
commit 0004d6410a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,8 +10,16 @@ set -eu -o pipefail
# - BUILDKITE_PULL_REQUEST
# - RENDER_PREVIEW_GITHUB_TOKEN
exit_status=$?
chromatic_publish_output=$(</dev/stdin)
if [ $exit_status -eq 0 ]; then
echo "$chromatic_publish_output"
else
echo "$chromatic_publish_output"
exit 1
fi
echo "$chromatic_publish_output"
# Chromatic preview url from Chromatic publish output (`-m 1` for getting first match)