Skip to content

Commit a720963

Browse files
authored
Merge pull request #3 from Modern-Programming-Club/feature/add-github-action
Feature/add GitHub action
2 parents 8d52920 + 22821c6 commit a720963

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

.github/workflows/notify-slack-on-pr-merge.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@ jobs:
88
notify:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Check if PR was merged
11+
- name: Get GitHub User Name
12+
id: get_username
13+
run: |
14+
USERNAME=$(curl -s "https://api.github.com/users/${{ github.actor }}" | jq -r '.name')
15+
if [ "$USERNAME" == "null" ]; then
16+
USERNAME="${{ github.actor }}"
17+
fi
18+
echo "USERNAME=$USERNAME" >> $GITHUB_ENV
19+
20+
- name: Send Slack Notification
1221
if: github.event.pull_request.merged == true
1322
uses: rtCamp/action-slack-notify@v2
1423
env:
1524
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
1625
SLACK_MESSAGE: |
17-
✅ PR Merged!
18-
🔗 Repository: `${{ github.repository }}`
19-
🛠 Merged by: `${{ github.actor }}`
20-
🚀 PR Title: `${{ github.event.pull_request.title }}`
21-
📝 PR Description: `${{ github.event.pull_request.body }}`
22-
🔗 PR URL: ${{ github.event.pull_request.html_url }}
26+
*PR Merged!*
27+
🚀 *${{ github.event.pull_request.title }}*
28+
🛠 Merged by: `${{ env.USERNAME }}`
29+
📝 Description:
30+
- ${{ github.event.pull_request.body }}
31+
🔗 *PR URL:* ${{ github.event.pull_request.html_url }}
2332
SLACK_USERNAME: "GitHub Actions"
2433
SLACK_ICON_EMOJI: ":white_check_mark:"

guide/github-action-test.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Github Action Test
2+

0 commit comments

Comments
 (0)