File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ #! /bin/bash
3+
4+ # write npm run output both to console and to build.log
5+ npm run build 2>&1 | tee build.log
6+ build_status=${PIPESTATUS[0]}
7+
8+ # if exist status from the npm run build is not 0
9+ # then exit with the status code from the npm run build
10+ if [ $build_status -ne 0 ]; then
11+ echo " Build failed. Exiting with status code $build_status "
12+ exit $build_status
13+ fi
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ set -x
4+
5+ COMMIT_SHORT_SHA=$( echo $CI_COMMIT_SHA | cut -c1-8)
6+
7+ STATUS=${1}
8+
9+
10+ if [ " $STATUS " = " success" ]; then
11+ MESSAGE=" Did a build without issues on \` $CI_REPO_NAME /$CI_COMMIT_BRANCH \` . Commit: _${CI_COMMIT_MESSAGE} _ (<$CI_COMMIT_URL |$COMMIT_SHORT_SHA >)"
12+
13+ curl -s -X POST -H " Content-Type: application/json" -d ' {
14+ "username": "' " $CI_COMMIT_AUTHOR " ' ",
15+ "icon_url": "' " $CI_COMMIT_AUTHOR_AVATAR " ' ",
16+ "attachments": [
17+ {
18+ "mrkdwn_in": ["text", "pretext"],
19+ "color": "#36a64f",
20+ "text": "' " $MESSAGE " ' "
21+ }
22+ ]
23+ }' " $DEVELOPERS_SLACK_WEBHOOK "
24+ exit 0
25+ fi
26+ export BUILD_LOG=$( cat ./build.log)
27+
28+ BUILD_LOG=$( echo $BUILD_LOG | sed ' s/"/\\"/g' )
29+
30+ MESSAGE=" Broke \` $CI_REPO_NAME /$CI_COMMIT_BRANCH \` with commit _${CI_COMMIT_MESSAGE} _ (<$CI_COMMIT_URL |$COMMIT_SHORT_SHA >)"
31+ CODE_BLOCK=" \`\`\` $BUILD_LOG \n\`\`\` "
32+
33+ echo " Sending slack message to developers $MESSAGE "
34+ # Send the message
35+ curl -sS -X POST -H " Content-Type: application/json" -d ' {
36+ "username": "' " $CI_COMMIT_AUTHOR " ' ",
37+ "icon_url": "' " $CI_COMMIT_AUTHOR_AVATAR " ' ",
38+ "attachments": [
39+ {
40+ "mrkdwn_in": ["text", "pretext"],
41+ "color": "#8A1C12",
42+ "text": "' " $CODE_BLOCK " ' ",
43+ "pretext": "' " $MESSAGE " ' "
44+ }
45+ ]
46+ }' " $DEVELOPERS_SLACK_WEBHOOK " 2>&1
Original file line number Diff line number Diff line change 1+ clone :
2+ git :
3+ image : woodpeckerci/plugin-git
4+ settings :
5+ partial : false
6+ depth : 5
7+
8+ steps :
9+ init-secrets :
10+ when :
11+ - event : push
12+ image : infisical/cli
13+ environment :
14+ INFISICAL_TOKEN :
15+ from_secret : VAULT_TOKEN
16+ commands :
17+ - infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
18+
19+ build :
20+ image : devforth/node20-pnpm:latest
21+ when :
22+ - event : push
23+ commands :
24+ - apt update && apt install -y rsync
25+ - . /woodpecker/deploy.vault.env
26+ - pnpm install
27+ - /bin/bash ./.woodpecker/buildRelease.sh
28+ - npm audit signatures
29+
30+ release :
31+ image : devforth/node20-pnpm:latest
32+ when :
33+ - event :
34+ - push
35+ branch :
36+ - main
37+ commands :
38+ - . /woodpecker/deploy.vault.env
39+ - pnpm exec semantic-release
40+
41+ slack-on-failure :
42+ image : curlimages/curl
43+ when :
44+ - event : push
45+ status : [failure]
46+ commands :
47+ - . /woodpecker/deploy.vault.env
48+ - /bin/sh ./.woodpecker/buildSlackNotify.sh failure
49+
50+ slack-on-success :
51+ image : curlimages/curl
52+ when :
53+ - event : push
54+ status : [success]
55+ commands :
56+ - . /woodpecker/deploy.vault.env
57+ - /bin/sh ./.woodpecker/buildSlackNotify.sh success
You can’t perform that action at this time.
0 commit comments