Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord webhook #52

Merged
merged 26 commits into from
Sep 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/discord-webook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on:
pull_request:
types: [opened, reopened, synchronize]
push:
branches:
- main
paths:
- "src/**"
- ".github/workflows/discord-webhook.yml"
jobs:
Discord-Notification:
name: Discord notification
runs-on: ubuntu-latest
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all history for all branches

- name: Get embed details
id: embed_details
run: |
echo "COMMIT_MESSAGE=$(git log --no-merges -1 --pretty="commit %h: %B")" >> $GITHUB_ENV
if [ "${{ github.event_name }}" == "pull_request" ]; then
if [ "${{ github.event.action }}" == "opened" ] || [ "${{ github.event.action }}" == "reopened" ]; then
echo "EMBED_TITLE=Pull Request: ${{ github.event.pull_request.title }} (#${{ github.event.pull_request.number }}) Opened" >> $GITHUB_ENV
else
echo "EMBED_TITLE=Pull Request: ${{ github.event.pull_request.title }} (#${{ github.event.pull_request.number }}) Updated" >> $GITHUB_ENV
fi
echo "EMBED_COLOR=2067276" >> $GITHUB_ENV
echo "THUMBNAIL_URL=https://raw.githubusercontent.com/ewei068/pokestar/refs/heads/main/media/images/misc/pikachu-pull.jpg" >> $GITHUB_ENV
else
echo "EMBED_TITLE=Triggered by Push to branch: ${{ github.ref }}" >> $GITHUB_ENV
echo "EMBED_COLOR=7419530" >> $GITHUB_ENV
echo "THUMBNAIL_URL=https://raw.githubusercontent.com/ewei068/pokestar/refs/heads/main/media/images/misc/pikachu-push.jpg" >> $GITHUB_ENV
fi

- name: Debug Log
env:
DISCORD_EMBEDS: '[{
"title": "${{ env.EMBED_TITLE }}",
"description": "${{ env.COMMIT_MESSAGE }}",
"color": ${{ env.EMBED_COLOR }},
"timestamp": "${{ github.event.pull_request.updated_at }}",
"author": { "name": "${{ github.event.sender.login }}", "icon_url": "${{ github.event.sender.avatar_url }}", "url": "https://github.com/${{ github.event.sender.login }}" },
"url": "${{ github.event.pull_request.html_url }}",
"thumbnail": { "url": "${{ env.THUMBNAIL_URL }}"}
}]'

run: |
echo '${{ env.DISCORD_EMBEDS }}'
echo 'DISCORD_EMBEDS=${{ env.DISCORD_EMBEDS }}' >> $GITHUB_ENV
- name: Discord notification
uses: Ilshidur/action-discord@master
Loading