Improve commit reading in GitHub Actions workflow #11
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: Build commit list | |
| id: commits | |
| run: | | |
| COMMIT_TEXT="" | |
| # Read each commit safely | |
| jq -c '.commits[]' < "${GITHUB_EVENT_PATH}" | while read commit; do | |
| MSG=$(echo "$commit" | jq -r '.message') | |
| URL=$(echo "$commit" | jq -r '.url') | |
| COMMIT_TEXT="${COMMIT_TEXT}- [$MSG]($URL)" | |
| done | |
| echo "commit_text<<EOF" >> $GITHUB_OUTPUT | |
| echo "$COMMIT_TEXT" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Send commits to Discord | |
| uses: sarisia/actions-status-discord@v1.15.4 | |
| with: | |
| webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
| title: "New push to ${{ github.ref_name }}" | |
| description: "${{ steps.commits.outputs.commit_text }}" | |
| noprefix: true | |
| nocontext: true |