Skip to content

Commit

Permalink
chore: add lark bot for new Issue and PR
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyutaotao committed Apr 22, 2024
1 parent 877b663 commit 1c8f472
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/issue-pr-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
BODY: ${{ github.event.issue.body }}
URL: ${{ github.server_url }}/${{ github.repository }}/issues/${{ github.event.issue.number }}
run: |
SHORT_BODY=$(echo "$BODY" | head -n 3) TITLE="New Issue Opened: $ISSUE_TITLE" DESCRIPTION="Issue by @$AUTHOR_ID: $SHORT_BODY. View more at $URL" ./scripts/alert/lark.js
SHORT_BODY=$(echo "$BODY" | head -n 3) TITLE="New Issue Opened: $ISSUE_TITLE" DESCRIPTION="Issue by @$AUTHOR_ID: $SHORT_BODY. View more at $URL" TPL_COLOR="blue" TPL_BTN_TYPE="primary" ./scripts/alert/lark.js
- name: Notify Lark for PR
if: github.event_name == 'pull_request'
Expand All @@ -35,5 +35,5 @@ jobs:
BODY: ${{ github.event.pull_request.body }}
URL: ${{ github.server_url }}/${{ github.repository }}/pull/${{ github.event.pull_request.number }}
run: |
SHORT_BODY=$(echo "$BODY" | head -n 3) TITLE="New PR Opened: $PR_TITLE" DESCRIPTION="PR by @$AUTHOR_ID: $SHORT_BODY. Check it out at $URL" ./scripts/alert/lark.js
SHORT_BODY=$(echo "$BODY" | head -n 3) TITLE="New PR Opened: $PR_TITLE" DESCRIPTION="PR by @$AUTHOR_ID: $SHORT_BODY. Check it out at $URL" TPL_COLOR="blue" TPL_BTN_TYPE="primary" ./scripts/alert/lark.js
6 changes: 4 additions & 2 deletions scripts/alert/lark.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const TITLE = process.env.TITLE;
const DESCRIPTION = process.env.DESCRIPTION;
const URL = process.env.URL;
const LARK_WEBHOOK_URL = process.env.LARK_WEBHOOK_URL;
const TPL_COLOR = process.env.TPL_COLOR || "red";
const TPL_BTN_TYPE = process.env.TPL_BTN_COLOR || "danger"; // default primary danger

if (!TITLE || !DESCRIPTION) {
throw new Error("please input title and description");
Expand All @@ -18,7 +20,7 @@ const res = await fetch(LARK_WEBHOOK_URL, {
msg_type: "interactive",
card: {
header: {
template: "red",
template: TPL_COLOR,
title: {
content: TITLE,
tag: "plain_text"
Expand All @@ -39,7 +41,7 @@ const res = await fetch(LARK_WEBHOOK_URL, {
tag: "plain_text"
},
url: URL,
type: "danger"
type: TPL_BTN_TYPE
}
]
}
Expand Down

0 comments on commit 1c8f472

Please sign in to comment.