Skip to content

Improve commit reading in GitHub Actions workflow #11

Improve commit reading in GitHub Actions workflow

Improve commit reading in GitHub Actions workflow #11

Workflow file for this run

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