-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97d590b
commit 5abd705
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
# Exit immediately if a command exits with a non-zero status. | ||
set -e | ||
# Enable the globstar shell option | ||
shopt -s globstar | ||
# Make sure we are inside the github workspace | ||
cd $GITHUB_WORKSPACE | ||
echo $STEPS_CONTEXT | ||
step=$1 | ||
status=$2 | ||
export BODYMESSAGE="$(git log -1 $GITHUB_SHA --pretty=oneline --abbrev-commit)" | ||
export BACKTICK='`'; | ||
export TIMESTAMP=$(date --utc +%FT%TZ); | ||
export GITHUB_ACTOR_NAME="$(git log -1 $GITHUB_SHA --pretty="%aN")"; | ||
export COMMIT_FORMATTED="[$BACKTICK${GITHUB_SHA:0:7}$BACKTICK](https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)"; | ||
|
||
if [[ "$status" == "success" ]]; | ||
then | ||
echo "Success build" | ||
if [ -z "$DISCORD_WEBHOOK_URL" ]; | ||
then | ||
echo "no need bot" | ||
else | ||
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; | ||
fi | ||
else | ||
echo "Build failed" | ||
if [ -z "$DISCORD_WEBHOOK_URL" ]; | ||
then | ||
echo "no need bot" | ||
else | ||
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; | ||
fi | ||
exit 1 | ||
fi | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# Exit immediately if a command exits with a non-zero status. | ||
set -e | ||
# Enable the globstar shell option | ||
shopt -s globstar | ||
|
||
pip install -U platformio | ||
platformio update | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: build-ci | ||
|
||
on: [pull_request, push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16.x' | ||
- name: Install libraries | ||
id: setuptools | ||
run: npm install | ||
continue-on-error: true | ||
- name: Build all files | ||
id: buildall | ||
run: npm run buildall | ||
continue-on-error: true | ||
- name: Failure check | ||
env: | ||
STEPS_CONTEXT: ${{ toJson(steps) }} | ||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | ||
if: steps.setuptools.outcome == 'failure' || steps.buildall.outcome == 'failure' | ||
run: bash ./.github/ci/final-check.sh "$GITHUB_RUN_ID" "failure" | ||
- name: Success check | ||
env: | ||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | ||
if: steps.setuptools.outcome == 'success' && steps.buildall.outcome == 'success' | ||
run: bash ./.github/ci/final-check.sh "$GITHUB_RUN_ID" "success" |