Skip to content

Commit

Permalink
chore: block message notifications from PRs and bots
Browse files Browse the repository at this point in the history
  • Loading branch information
pixiake authored Mar 20, 2024
1 parent f8c2552 commit 38055b3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/issue_comment_webhook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ jobs:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
with:
script: |
console.log(context);
console.log(JSON.stringify(context, null, 2));
if (context.payload.sender.login === "ks-ci-bot") return;
const axios = require('axios');
if (context.payload.sender.type === 'Bot') return;
if (context.payload.issue.html_url.indexOf('/pull/') > 0) return;
const issue = context.payload.issue;
const comment = context.payload.comment;
var subject = {};
Expand All @@ -34,12 +35,12 @@ jobs:
action = "issue";
subject = issue;
};
const payload = {
const webhook_body = {
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);
console.log(JSON.stringify(webhook_body, null, 2));
const axios = require('axios');
await axios.post(process.env.WEBHOOK_URL, webhook_body);

0 comments on commit 38055b3

Please sign in to comment.