# HG changeset patch
# User Arthur Lutz <arthur.lutz@logilab.fr>
# Date 1594287022 -7200
#      Thu Jul 09 11:30:22 2020 +0200
# Node ID 87f4c19eecd8f4ebb466f423dc7fbfbd50108353
# Parent  28276a441fd7d05d63128a41e15093fe34d27d7a
[builder] add sentry-cli (which requires SENTRY_DSN env variable)

Switch to bash

diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -54,6 +54,7 @@
 - `CLEAN`: if set, will perform a `gatsby clean` before building.
 - `BUCKET`: if set, will copy public site to given bicket. Need ~.aws/config to be
   correctly setup.
+- `SENTRY_DSN`: if set, will report errors in builder to a sentry project.
 
 ## Usage
 
diff --git a/docker-scripts/builder.sh b/docker-scripts/builder.sh
--- a/docker-scripts/builder.sh
+++ b/docker-scripts/builder.sh
@@ -1,4 +1,5 @@
-#!/bin/sh
+#!/bin/bash
+eval "$(sentry-cli bash-hook)"
 
 rm -f /var/run/builder.pid   # in case the build has been killed
                              # without deleting the file
# HG changeset patch
# User Arthur Lutz <arthur.lutz@logilab.fr>
# Date 1594300603 -7200
#      Thu Jul 09 15:16:43 2020 +0200
# Node ID 1988b6f496a298cee843f9b2aef566d4367967ca
# Parent  87f4c19eecd8f4ebb466f423dc7fbfbd50108353
[builder.sh] use sentry-cli to send build.log when it fails

diff --git a/docker-scripts/builder.sh b/docker-scripts/builder.sh
--- a/docker-scripts/builder.sh
+++ b/docker-scripts/builder.sh
@@ -17,8 +17,15 @@
 else
   echo "Cleaning cache...";
 fi
-gatsby build
-echo "Build finished."
+set -o pipefail
+
+if gatsby build --no-colors | tee /tmp/build.log ; then
+  echo "Build finished."
+else
+  echo "Build failed."
+  sentry-cli send-event -m "Build failed" --logfile /tmp/build.log
+fi
+
 
 if [ $BUCKET ]; then
   echo "Launching aws s3 sync to $BUCKET"