Skip to content

Commit

Permalink
Create issue_comment_webhook.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
pixiake committed Mar 6, 2024
1 parent eea85c6 commit f8c2552
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/issue_comment_webhook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Issue Comment WeCom Webhook

on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]

jobs:
send_to_webhook:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: "20.x"
- run: npm install axios
- name: Send issue/comment to WeCom webhook
uses: actions/github-script@v7
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
with:
script: |
console.log(context);
if (context.payload.sender.login === "ks-ci-bot") return;
const axios = require('axios');
const issue = context.payload.issue;
const comment = context.payload.comment;
var subject = {};
var action = '';
if (comment) {
action = "comment";
subject = comment;
} else {
action = "issue";
subject = issue;
};
const payload = {
msgtype: 'markdown',
markdown: {
content: `[${context.payload.sender.login}](${context.payload.sender.html_url}) ${context.payload.action} ${action} [${issue.title}](${subject.html_url})\n${subject.body}`,
},
};
const formattedPayload = JSON.stringify(payload, null, 2);
console.log(formattedPayload);
await axios.post(process.env.WEBHOOK_URL, payload);

0 comments on commit f8c2552

Please sign in to comment.