Skip to content

Commit bca8602

Browse files
committed
fix: allow html parameter to be optional in sendEmail method
1 parent 5a9d8d7 commit bca8602

4 files changed

Lines changed: 111 additions & 2 deletions

File tree

.woodpecker/buildRelease.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
pnpm run build 2>&1 | tee build.log
4+
build_status=${PIPESTATUS[0]}
5+
6+
if [ $build_status -ne 0 ]; then
7+
echo "Build failed. Exiting with status code $build_status"
8+
exit $build_status
9+
fi

.woodpecker/buildSlackNotify.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
if [ "$STATUS" = "success" ]; then
10+
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
11+
12+
curl -s -X POST -H "Content-Type: application/json" -d '{
13+
"username": "'"$CI_COMMIT_AUTHOR"'",
14+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
15+
"attachments": [
16+
{
17+
"mrkdwn_in": ["text", "pretext"],
18+
"color": "#36a64f",
19+
"text": "'"$MESSAGE"'"
20+
}
21+
]
22+
}' "$DEVELOPERS_SLACK_WEBHOOK"
23+
exit 0
24+
fi
25+
export BUILD_LOG=$(cat ./build.log)
26+
27+
BUILD_LOG=$(echo $BUILD_LOG | sed 's/"/\\"/g')
28+
29+
MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
30+
CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
31+
32+
echo "Sending slack message to developers $MESSAGE"
33+
curl -sS -X POST -H "Content-Type: application/json" -d '{
34+
"username": "'"$CI_COMMIT_AUTHOR"'",
35+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
36+
"attachments": [
37+
{
38+
"mrkdwn_in": ["text", "pretext"],
39+
"color": "#8A1C12",
40+
"text": "'"$CODE_BLOCK"'",
41+
"pretext": "'"$MESSAGE"'"
42+
}
43+
]
44+
}' "$DEVELOPERS_SLACK_WEBHOOK" 2>&1

.woodpecker/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
- . /woodpecker/deploy.vault.env
25+
- pnpm install
26+
- /bin/bash ./.woodpecker/buildRelease.sh
27+
- npm audit signatures
28+
29+
release:
30+
image: devforth/node20-pnpm:latest
31+
when:
32+
- event:
33+
- push
34+
branch:
35+
- main
36+
commands:
37+
- . /woodpecker/deploy.vault.env
38+
- pnpm exec semantic-release
39+
40+
slack-on-failure:
41+
image: curlimages/curl
42+
when:
43+
- event: push
44+
status: [failure]
45+
commands:
46+
- . /woodpecker/deploy.vault.env
47+
- /bin/sh ./.woodpecker/buildSlackNotify.sh failure
48+
49+
slack-on-success:
50+
image: curlimages/curl
51+
when:
52+
- event: push
53+
status: [success]
54+
commands:
55+
- . /woodpecker/deploy.vault.env
56+
- /bin/sh ./.woodpecker/buildSlackNotify.sh success

index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class EmailAdapterMailgun implements EmailAdapter {
2323
from: string,
2424
to: string,
2525
text: string,
26-
html: string,
26+
html: string | undefined,
2727
subject: string
2828
): Promise<{ error?: string; ok?: boolean }> {
2929
const mailgun = new Mailgun(formData);
@@ -39,7 +39,7 @@ export default class EmailAdapterMailgun implements EmailAdapter {
3939
to,
4040
subject,
4141
text,
42-
html,
42+
...(html ? { html } : {}),
4343
});
4444
return { ok: true };
4545
} catch (error: any) {

0 commit comments

Comments
 (0)