Skip to content

refactor: encapsulate handle_message params into MessageContext struc… #17

refactor: encapsulate handle_message params into MessageContext struc…

refactor: encapsulate handle_message params into MessageContext struc… #17

name: Notify Discord
on:
pull_request:
types: [opened, reopened]
issues:
types: [opened, reopened]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send to Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
EVENT_NAME: ${{ github.event_name }}
EVENT_ACTION: ${{ github.event.action }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_NUMBER: ${{ github.event.pull_request.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_URL: ${{ github.event.issue.html_url }}
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPO: ${{ github.repository }}
run: |
[ -z "$DISCORD_WEBHOOK_URL" ] && { echo "::warning::DISCORD_WEBHOOK_URL not set"; exit 0; }
if [ "$EVENT_NAME" = "pull_request" ]; then
TITLE="$PR_TITLE"
URL="$PR_URL"
AUTHOR="$PR_AUTHOR"
NUM="$PR_NUMBER"
TYPE="pr_${EVENT_ACTION}"
LABEL="PR #${NUM}"
else
TITLE="$ISSUE_TITLE"
URL="$ISSUE_URL"
AUTHOR="$ISSUE_AUTHOR"
NUM="$ISSUE_NUMBER"
TYPE="issue_${EVENT_ACTION}"
LABEL="Issue #${NUM}"
fi
PAYLOAD=$(jq -n \
--arg content "[GH-EVENT] repo:${REPO} action:${TYPE} ${LABEL}
**${TITLE}**

Check failure on line 48 in .github/workflows/notify-discord.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/notify-discord.yml

Invalid workflow file

You have an error in your yaml syntax on line 48
by ${AUTHOR}
${URL}" \
'{"content": $content}')
curl --fail-with-body -s -H "Content-Type: application/json" -d "$PAYLOAD" "$DISCORD_WEBHOOK_URL"