Send comments from updates #4842
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Send comments from updates | |
on: | |
issue_comment: { types: created } | |
jobs: | |
apply-label: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
env: | |
TEAMS_INCOMING_WEBHOOK_URL: ${{secrets.TEAMS_INCOMING_WEBHOOK_URL}} | |
with: | |
github-token: ${{github.token}} | |
script: | | |
const fetch = require("node-fetch") | |
const teamsURL = process.env.TEAMS_INCOMING_WEBHOOK_URL | |
if (!teamsURL) return console.log("Skipping sending the message because it's not the update repo") | |
// console.log(context.payload) | |
const issue = context.payload.issue | |
const issue_comment = context.payload.comment | |
if (issue_comment.user.login !== "orta") return console.log(`Skipping because not orta`) | |
if (issue.id !== 524510895) return console.log(`Skipping sending the message because ${issue.id} is not the update post`) | |
const message = { | |
"@type": "MessageCard", | |
"@context": "https://schema.org/extensions", | |
summary: "Website update", | |
themeColor: "0078D7", | |
title: 'Website update', | |
sections: [ | |
{ | |
activityTitle: "Comment", | |
activitySubtitle: issue_comment.created_at, | |
activityImage: issue_comment.user.avatar_url, | |
"text": issue_comment.body | |
} | |
], | |
potentialAction: [ | |
{ | |
"@type": "OpenUri", | |
name: "View in GitHub", | |
targets: [ | |
{ | |
os: "default", | |
uri: issue_comment.html_url | |
} | |
] | |
} | |
] | |
}; | |
fetch(teamsURL, { | |
method: "post", | |
body: JSON.stringify(message), | |
headers: { "Content-Type": "application/json" } | |
}); |