Skip to content

test

test #2

name: Notify Slack on New Issue or PR
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send Slack notification
run: |
if [[ "${{ github.event_name }}" == "issues" ]]; then
TYPE="Issue"
TITLE="${{ github.event.issue.title }}"
URL="${{ github.event.issue.html_url }}"
USER="${{ github.event.issue.user.login }}"
else
TYPE="Pull Request"
TITLE="${{ github.event.pull_request.title }}"
URL="${{ github.event.pull_request.html_url }}"
USER="${{ github.event.pull_request.user.login }}"
fi
PAYLOAD=$(jq -n \
--arg type "$TYPE" \
--arg title "$TITLE" \
--arg url "$URL" \
--arg user "$USER" \
'{
text: "*New GitHub \($type)* :sparkles:",
attachments: [
{
color: "#36a64f",
title: $title,
title_link: $url,
fields: [
{
title: "Author",
value: $user,
short: true
}
]
}
]
}')
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" $SLACK_WEBHOOK_URL
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}