Skip to content

Commit fee0b50

Browse files
committed
fix: fix release script
1 parent b9246c7 commit fee0b50

2 files changed

Lines changed: 31 additions & 13 deletions

File tree

.woodpecker/buildSlackNotify.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#!/bin/sh
22

3+
set -x
34

45
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
56

7+
STATUS=${1}
68

7-
if [ "$CI_STEP_STATUS" = "success" ]; then
9+
10+
if [ "$STATUS" = "success" ]; then
811
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
912

1013
curl -s -X POST -H "Content-Type: application/json" -d '{
@@ -22,13 +25,14 @@ if [ "$CI_STEP_STATUS" = "success" ]; then
2225
fi
2326
export BUILD_LOG=$(cat ./build.log)
2427

28+
BUILD_LOG=$(echo $BUILD_LOG | sed 's/"/\\"/g')
2529

2630
MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
2731
CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
2832

2933
echo "Sending slack message to developers $MESSAGE"
3034
# Send the message
31-
curl -X POST -H "Content-Type: application/json" -d '{
35+
curl -sS -X POST -H "Content-Type: application/json" -d '{
3236
"username": "'"$CI_COMMIT_AUTHOR"'",
3337
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
3438
"attachments": [
@@ -39,4 +43,4 @@ curl -X POST -H "Content-Type: application/json" -d '{
3943
"pretext": "'"$MESSAGE"'"
4044
}
4145
]
42-
}' "$DEVELOPERS_SLACK_WEBHOOK"
46+
}' "$DEVELOPERS_SLACK_WEBHOOK" 2>&1

.woodpecker/release.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,42 @@ steps:
1616
commands:
1717
- infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
1818

19-
release:
19+
build:
2020
image: node:20
2121
when:
2222
- event: push
23-
volumes:
24-
- /var/run/docker.sock:/var/run/docker.sock
2523
commands:
26-
# install rsync
2724
- apt update && apt install -y rsync
28-
- export $(cat /woodpecker/deploy.vault.env | xargs)
25+
- . /woodpecker/deploy.vault.env
2926
- npm clean-install
3027
- /bin/bash ./.woodpecker/buildRelease.sh
3128
- npm audit signatures
29+
30+
release:
31+
image: node:20
32+
when:
33+
- event:
34+
- push
35+
branch:
36+
- main
37+
commands:
38+
- . /woodpecker/deploy.vault.env
3239
- npx semantic-release
3340

3441
slack-on-failure:
42+
image: curlimages/curl
3543
when:
3644
- event: push
37-
status: [failure, success]
38-
- event: push
45+
status: [failure]
46+
commands:
47+
- . /woodpecker/deploy.vault.env
48+
- /bin/sh ./.woodpecker/buildSlackNotify.sh failure
49+
50+
slack-on-success:
3951
image: curlimages/curl
52+
when:
53+
- event: push
54+
status: [success]
4055
commands:
41-
- export $(cat /woodpecker/deploy.vault.env | xargs)
42-
- /bin/sh ./.woodpecker/buildSlackNotify.sh
43-
56+
- . /woodpecker/deploy.vault.env
57+
- /bin/sh ./.woodpecker/buildSlackNotify.sh success

0 commit comments

Comments
 (0)