Skip to content

Commit 0a91472

Browse files
committed
Add discord notification
Update CI badge
1 parent 1589501 commit 0a91472

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

.github/ci/final-check.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
# Exit immediately if a command exits with a non-zero status.
3+
set -e
4+
# Enable the globstar shell option
5+
shopt -s globstar
6+
# Make sure we are inside the github workspace
7+
cd $GITHUB_WORKSPACE
8+
echo $STEPS_CONTEXT
9+
step=$1
10+
status=$2
11+
export BODYMESSAGE="$(git log -1 $GITHUB_SHA --pretty=oneline --abbrev-commit)"
12+
export BACKTICK='`';
13+
export TIMESTAMP=$(date --utc +%FT%TZ);
14+
export GITHUB_ACTOR_NAME="$(git log -1 $GITHUB_SHA --pretty="%aN")";
15+
export COMMIT_FORMATTED="[$BACKTICK${GITHUB_SHA:0:7}$BACKTICK](https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)";
16+
17+
if [[ "$status" == "success" ]];
18+
then
19+
echo "Success build"
20+
if [ -z "$DISCORD_WEBHOOK_URL" ];
21+
then
22+
echo "no need bot"
23+
else
24+
curl -v -H User-Agent:bot -H Content-Type:application/json -d '{"avatar_url":"https://pngimg.com/uploads/github/github_PNG90.png","username":"github-action","embeds":[{"author":{"name":"Build #'"$step"' Passed - '"$GITHUB_ACTOR_NAME"'","url":"https://github.com/'"$GITHUB_REPOSITORY"'/actions/runs/'"$GITHUB_RUN_ID"'"},"url":"https://github.com/'"$GITHUB_REPOSITORY"'/actions/runs/'"$GITHUB_RUN_ID"'","title":"['"$GITHUB_REPOSITORY"':job#'"$GITHUB_RUN_NUMBER"'] ","color":65280,"fields":[{"name":"_ _", "value": "'"$COMMIT_FORMATTED"' - '"$BODYMESSAGE"'"}],"timestamp":"'"$TIMESTAMP"'","footer":{"text":"ESP3D CI"}}]}' $DISCORD_WEBHOOK_URL;
25+
fi
26+
else
27+
echo "Build failed"
28+
if [ -z "$DISCORD_WEBHOOK_URL" ];
29+
then
30+
echo "no need bot"
31+
else
32+
curl -v -H User-Agent:bot -H Content-Type:application/json -d '{"avatar_url":"https://pngimg.com/uploads/github/github_PNG90.png","username":"github-action","embeds":[{"author":{"name":"Build #'"$step"' Failed - '"$GITHUB_ACTOR_NAME"'","url":"https://github.com/'"$GITHUB_REPOSITORY"'/actions/runs/'"$GITHUB_RUN_ID"'"},"url":"https://github.com/'"$GITHUB_REPOSITORY"'/actions/runs/'"$GITHUB_RUN_ID"'","title":"['"$GITHUB_REPOSITORY"':job#'"$GITHUB_RUN_NUMBER"'] ","color":16711680,"fields":[{"name":"_ _", "value": "'"$COMMIT_FORMATTED"' - '"$BODYMESSAGE"'"}],"timestamp":"'"$TIMESTAMP"'","footer":{"text":"ESP3D CI"}}]}' $DISCORD_WEBHOOK_URL;
33+
fi
34+
exit 1
35+
fi
36+
37+

.github/workflows/build-ci.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,21 @@ jobs:
1212
with:
1313
node-version: '16.x'
1414
- name: Install libraries
15+
id: setuptools
1516
run: npm install
17+
continue-on-error: true
1618
- name: Build all files
19+
id: buildall
1720
run: npm run buildall
1821
continue-on-error: true
19-
- name: Check Failures
20-
if: ${{ failure() }}
21-
run: echo "Build failed"
22+
- name: Failure check
23+
env:
24+
STEPS_CONTEXT: ${{ toJson(steps) }}
25+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
26+
if: steps.setuptools.outcome == 'failure' || steps.buildall.outcome == 'failure'
27+
run: bash ./.github/ci/final-check.sh "$GITHUB_RUN_ID" "failure"
28+
- name: Success check
29+
env:
30+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
31+
if: steps.setuptools.outcome == 'success' && steps.buildall.outcome == 'success'
32+
run: bash ./.github/ci/final-check.sh "$GITHUB_RUN_ID" "success"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Rewrite per @alxblog suggestion to use proper Preactjs API and lighter code: use
77

88
Only compatible with [ESP3DLib 3.0](https://github.com/luc-github/ESP3DLib/tree/3.0) , [ESP3D 3.0](https://github.com/luc-github/ESP3D/tree/3.0), [grblHAL](https://github.com/grblHAL)
99

10-
[Latest development version ![Development Version](https://img.shields.io/badge/Devt-v3.0-yellow?style=plastic)](https://github.com/luc-github/ESP3D-WEBUI/tree/3.0) ![GitHub last commit (branch)](https://img.shields.io/github/last-commit/luc-github/ESP3D-WEBUI/3.0?style=plastic) [![Travis (.org) branch](https://img.shields.io/travis/luc-github/ESP3D-WEBUI/3.0?style=plastic)](https://travis-ci.org/github/luc-github/ESP3D-WEBUI) [![Project Page ESP3D 3.0](https://img.shields.io/badge/Project%20page-ESP3D%203.0-blue?style=plastic)](https://github.com/users/luc-github/projects/1/views/1)
10+
[Latest development version ![Development Version](https://img.shields.io/badge/Devt-v3.0-yellow?style=plastic)](https://github.com/luc-github/ESP3D-WEBUI/tree/3.0) ![GitHub last commit (branch)](https://img.shields.io/github/last-commit/luc-github/ESP3D-WEBUI/3.0?style=plastic) [![github-ci](https://github.com/luc-github/ESP3D-WeBUI/workflows/build-ci/badge.svg)](https://github.com/luc-github/ESP3D-WEBUI/actions/workflows/build-ci.yml) [![Project Page ESP3D 3.0](https://img.shields.io/badge/Project%20page-ESP3D%203.0-blue?style=plastic)](https://github.com/users/luc-github/projects/1/views/1)
1111

1212
### Setup development tools
1313

0 commit comments

Comments
 (0)