From d4be89c487a60e6f8426c6465692727baebd1a05 Mon Sep 17 00:00:00 2001 From: Vanessa Freudenberg Date: Tue, 5 Mar 2024 18:58:48 -0800 Subject: [PATCH] Notify slack about build failures --- .github/workflows/deploy-to-pages.yml | 11 ++++++----- scripts/build-pages.sh | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-to-pages.yml b/.github/workflows/deploy-to-pages.yml index 8d996a75..e9326d56 100644 --- a/.github/workflows/deploy-to-pages.yml +++ b/.github/workflows/deploy-to-pages.yml @@ -1,7 +1,7 @@ -# Workflow to build a GitHub Pages site for multiple branches simultaneously +# Workflow to build a GitHub Pages site for all examples and tutorials +# and deploy it to https://croquet.github.io/worldcore/ -# NOTE: to make this work, in GitHub Settings under Pages – Build and Deployment -# change Source from "Deploy from a branch" to "GitHub Actions"! +# The actual work is done in scripts/build-pages.sh # NOTE: to make this work, in GitHub Settings under Pages – Build and Deployment # change Source from "Deploy from a branch" to "GitHub Actions"! @@ -27,7 +27,8 @@ concurrency: jobs: deploy: - # only run on main repo + # only run on main repo and not forks + # (change this in your fork if you want it there) if: github.repository == 'croquet/worldcore' environment: name: github-pages @@ -39,7 +40,7 @@ jobs: with: fetch-depth: 0 # fetch full history - - name: Setup Pages + - name: Configure pages uses: actions/configure-pages@v4 - name: Use Node.js 18 diff --git a/scripts/build-pages.sh b/scripts/build-pages.sh index ffe62eed..62800ae2 100755 --- a/scripts/build-pages.sh +++ b/scripts/build-pages.sh @@ -11,6 +11,7 @@ npx lerna bootstrap || exit 1 rm -rf _site mkdir _site LINKS=() +FAILED=() TOP=$(git rev-parse --show-toplevel) for DIR in tutorials examples ; do cd $TOP @@ -36,6 +37,7 @@ for DIR in tutorials examples ; do cat build.log >> ../../_site/$APP/index.html echo "" >> ../../_site/$APP/index.html LINKS+=("

${DATE} ${APP} BUILD FAILED (log)

") + FAILED+=($APP) fi mv -v build.log ../../_site/$APP/ done @@ -75,3 +77,18 @@ cat > _site/index.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}\"" + echo curl -X POST -H 'Content-type: application/json' --data "${JSON}\"}" $SLACK_HOOK_URL + else + echo + echo "=== No SLACK_HOOK_URL set, not sending slack message ===" + fi +fi