This file contains hidden or 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: Discord Push Notifications | |
| on: | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| notify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send all commits to Discord | |
| run: | | |
| REPO="${{ github.repository }}" | |
| ACTOR="${{ github.actor }}" | |
| COMMIT_TEXT="" | |
| # Loop through all commits in the push | |
| for commit in $(jq -c '.commits[]' < "${GITHUB_EVENT_PATH}"); do | |
| COMMIT_MSG=$(echo "$commit" | jq -r '.message') | |
| COMMIT_URL=$(echo "$commit" | jq -r '.url') | |
| COMMIT_TEXT="$COMMIT_TEXT- [$COMMIT_MSG]($COMMIT_URL)\n" | |
| done | |
| # Prepare payload with proper newlines | |
| PAYLOAD=$(jq -n --arg content "$ACTOR pushed to **main** in [$REPO](https://github.com/$REPO): | |
| $COMMIT_TEXT" '{content: $content}') | |
| # Send to Discord | |
| curl -H "Content-Type: application/json" -d "$PAYLOAD" ${{ secrets.DISCORD_WEBHOOK }} |