Skip to content

Commit 0507a29

Browse files
Enhance Discord commit notification workflow
1 parent 773760b commit 0507a29

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ jobs:
1111
- name: Send all commits to Discord
1212
run: |
1313
REPO="${{ github.repository }}"
14+
BRANCH="${GITHUB_REF##*/}" # dynamically get branch name
1415
ACTOR="${{ github.actor }}"
1516
COMMIT_TEXT=""
1617
17-
# Loop through all commits in the push
18-
for commit in $(jq -c '.commits[]' < "${GITHUB_EVENT_PATH}"); do
18+
# Loop through all commits safely
19+
jq -c '.commits[]' < "${GITHUB_EVENT_PATH}" | while read commit; do
1920
COMMIT_MSG=$(echo "$commit" | jq -r '.message')
2021
COMMIT_URL=$(echo "$commit" | jq -r '.url')
21-
COMMIT_TEXT="$COMMIT_TEXT- [$COMMIT_MSG]($COMMIT_URL)\n"
22+
COMMIT_TEXT="${COMMIT_TEXT}- [$COMMIT_MSG]($COMMIT_URL)"
2223
done
2324
2425
# Prepare payload with proper newlines
25-
PAYLOAD=$(jq -n --arg content "$ACTOR pushed to **main** in [$REPO](https://github.com/$REPO):
26+
PAYLOAD=$(jq -n --arg content "🚀 $ACTOR pushed to **$BRANCH** in [$REPO](https://github.com/$REPO):
2627
$COMMIT_TEXT" '{content: $content}')
2728
2829
# Send to Discord

0 commit comments

Comments
 (0)