Skip to content

Commit

Permalink
chore: Add lark notification for new Issue and PR (#6313)
Browse files Browse the repository at this point in the history
* chore: add lark bot for new Issue and PR

* chore: add lark bot for new Issue and PR

* chore: add lark bot for new Issue and PR

* chore: add lark bot for new Issue and PR

* chore: add lark bot for new Issue and PR

* chore: add lark bot for new Issue and PR

* chore: add lark bot for new Issue and PR

* chore: add lark bot for new Issue and PR
  • Loading branch information
yuyutaotao authored Apr 22, 2024
1 parent d2235ce commit ef4201b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/teams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ team:
- "@zhoushaw"
- "@ulivz"
- "@LingyuCoder"
- "@yuyutaotao"
54 changes: 54 additions & 0 deletions .github/workflows/issue-pr-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Notify Lark on Issue and PR

on:
issues:
types: [opened]
pull_request:
types: [opened]

jobs:
notify-lark:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Check if triggered by project member
id: check_member
if: github.event.sender.type == 'User'
env:
REPO_OWNER: ${{ github.repository_owner }}
GH_TOKEN: ${{ github.token }}
run: |
SENDER=${{ github.event.sender.login }}
MEMBER=$(gh api /orgs/$REPO_OWNER/members/$SENDER | jq -r '.id')
if [[ -n $MEMBER ]]; then
echo "::set-output name=skip::true"
echo "Workflow triggered by a project member: $SENDER , will NOT trigger lark notify"
else
echo "::set-output name=skip::false"
fi
- name: Notify Lark for Issue
if: steps.check_member.outputs.skip != 'true' && github.event_name == 'issues'
env:
LARK_WEBHOOK_URL: ${{ secrets.LARK_WEBHOOK_URL }}
ISSUE_TITLE: ${{ github.event.issue.title }}
AUTHOR_ID: ${{ github.event.issue.user.login }}
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" TPL_COLOR="blue" TPL_BTN_TYPE="primary" ./scripts/alert/lark.js
- name: Notify Lark for PR
if: steps.check_member.outputs.skip != 'true' && github.event_name == 'pull_request'
env:
LARK_WEBHOOK_URL: ${{ secrets.LARK_WEBHOOK_URL }}
PR_TITLE: ${{ github.event.pull_request.title }}
AUTHOR_ID: ${{ github.event.pull_request.user.login }}
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" 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_TYPE || "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

2 comments on commit ef4201b

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs, self-hosted, Linux, ci ❌ failure
_selftest, ubuntu-latest ✅ success
nx, ubuntu-latest ✅ success
rspress, ubuntu-latest ✅ success
rsbuild, ubuntu-latest ✅ success
compat, ubuntu-latest ✅ success
examples, ubuntu-latest ✅ success

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-04-22 72638cb) Current Change
10000_development-mode + exec 2.67 s ± 31 ms 2.68 s ± 50 ms +0.61 %
10000_development-mode_hmr + exec 685 ms ± 7.4 ms 688 ms ± 8.3 ms +0.54 %
10000_production-mode + exec 2.46 s ± 29 ms 2.51 s ± 65 ms +1.90 %
arco-pro_development-mode + exec 2.47 s ± 80 ms 2.52 s ± 101 ms +2.28 %
arco-pro_development-mode_hmr + exec 429 ms ± 1.3 ms 432 ms ± 4.8 ms +0.54 %
arco-pro_development-mode_hmr_intercept-plugin + exec 440 ms ± 4.1 ms 444 ms ± 2.4 ms +0.76 %
arco-pro_development-mode_intercept-plugin + exec 3.23 s ± 71 ms 3.29 s ± 52 ms +1.98 %
arco-pro_production-mode + exec 3.93 s ± 107 ms 4.01 s ± 108 ms +2.02 %
arco-pro_production-mode_intercept-plugin + exec 4.73 s ± 74 ms 4.76 s ± 62 ms +0.61 %
threejs_development-mode_10x + exec 2.05 s ± 21 ms 2.06 s ± 26 ms +0.52 %
threejs_development-mode_10x_hmr + exec 746 ms ± 11 ms 762 ms ± 17 ms +2.21 %
threejs_production-mode_10x + exec 5.16 s ± 40 ms 5.22 s ± 57 ms +1.30 %

Please sign in to comment.