Skip to content

Commit

Permalink
Create comments.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
zentron authored Feb 12, 2024
1 parent 66a300b commit 7a12576
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/comments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
on: issue_comment

jobs:
pr_commented:
name: PR comment
runs-on: ubuntu-latest
steps:
- run: echo '${{ toJSON(github) }}'
- run: echo '${{ github.event.comment.author_association }}'
- name: Calculate some required properties
run: |
DAYS_OLD=$(( ($(date -d "${{ github.event.comment.created_at }}" +%s) - $(date -d "${{ github.event.issue.created_at }}" +%s)) / 86400 ))
echo "DAYS_OLD=$DAYS_OLD" >> $GITHUB_ENV
echo "TYPE=${{ github.event.issue.pull_request && 'PR' || 'Issue' }}" >> $GITHUB_ENV
- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
# Slack channel id, channel name, or user id to post message.
# See also: https://api.slack.com/methods/chat.postMessage#channels
channel-id: ${{ vars.SLACK_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":comment: Comment Added by Non Octopus user to ${{ env.TYPE }} #${{ github.event.issue.number }} - ${{ github.event.issue.title }}",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Repo:* <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>"
},
{
"type": "mrkdwn",
"text": "*${{ env.TYPE }}:* <${{ github.event.comment.html_url }}|#${{ github.event.issue.number }} - ${{ github.event.issue.title }}> _(${{ env.DAYS_OLD }} days old)_"
}
]
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "${{ github.event.sender.avatar_url }}",
"alt_text": "${{ github.event.sender.login }}"
},{
"type": "mrkdwn",
"text": "<${{ github.event.sender.html_url }}|${{ github.event.sender.login }}>"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ${{ toJSON(github.event.comment.body) }}
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<${{github.event.comment.html_url}}|View comment>"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 comments on commit 7a12576

Please sign in to comment.