Skip to content

Commit

Permalink
Update build-pages.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
codefrau committed Mar 6, 2024
1 parent 1e83eb6 commit cbb14f7
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions scripts/build-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rm -rf _site
mkdir _site
LINKS=()
FAILED=()
SUCCESS=()
TOP=$(git rev-parse --show-toplevel)
for DIR in tutorials examples ; do
cd $TOP
Expand All @@ -31,6 +32,7 @@ for DIR in tutorials examples ; do
if [ $BUILD_ERROR -eq 0 ] ; then
mv -v dist ../../_site/$APP
LINKS+=("<p>${DATE} <a href=\"${APP}/\"><b>${APP}</b></a> (<a href=\"${APP}/build.log\">log</a>)</p>")
SUCCESS+=($APP)
else
mkdir ../../_site/$APP
echo "<H1>Build failed</h1><pre>" > ../../_site/$APP/index.html
Expand Down Expand Up @@ -78,17 +80,20 @@ cat > _site/index.html <<EOF
</html>
EOF

NUM_FAILED=${#FAILED[@]}
if [ $NUM_FAILED -gt 0 ] ; then
if [ -n "$SLACK_HOOK_URL" ] ; then
echo
echo "=== Sending slack message ==="
URL="https://croquet.github.io/worldcore/"
APPS=$(printf -- "- %s\\\\n" "${FAILED[@]}")
JSON="{\"text\": \"πŸ€– *Worldcore build failed for ${NUM_FAILED} apps* πŸ€–\n${URL}\n${APPS}\""
curl -X POST -H 'Content-type: application/json' --data "${JSON}\"}" $SLACK_HOOK_URL
if [ -n "$SLACK_HOOK_URL" ] ; then
echo
echo "=== Sending slack message ==="
URL="https://croquet.github.io/worldcore/"
NUM_FAILED=${#FAILED[@]}
NUM_TOTAL=$((${#SUCCESS[@]} + ${#FAILED[@]}))
if [ $NUM_FAILED -eq 0 ] ; then
JSON="{\"text\": \"😍 *Worldcore build succeeded for all apps* 😍\n${URL}\"}"
else
echo
echo "=== No SLACK_HOOK_URL set, not sending slack message ==="
APPS=$(printf "β€’ %s\\\\n" "${FAILED[@]}")
JSON="{\"text\": \"πŸ’© *Worldcore builds failed for ${NUM_FAILED}/${NUM_TOTAL} apps* πŸ’©\n${URL}\n${APPS}\"}"
fi
curl -sSX POST -H 'Content-type: application/json' --data "${JSON}" $SLACK_HOOK_URL
else
echo
echo "=== No SLACK_HOOK_URL set, not sending slack message ==="
fi

0 comments on commit cbb14f7

Please sign in to comment.