Skip to content

Commit 03aa454

Browse files
committed
chore: 슬랙 PR 워크플로우
1 parent bc18830 commit 03aa454

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

.github/workflows/pr-slack-notify.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,38 @@ jobs:
88
notify:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Set reviewers based on repository
11+
- name: Set reviewers based on branch
1212
id: set-reviewers
1313
run: |
14-
REPO_NAME="${{ github.repository }}"
15-
if [[ $REPO_NAME == *"dev-fe"* ]]; then
14+
TARGET_BRANCH="${{ github.event.pull_request.base.ref }}"
15+
if [[ $TARGET_BRANCH == "dev-fe" ]]; then
1616
echo "team=FE" >> $GITHUB_OUTPUT
1717
echo "reviewers=<@U07GSBHPCPR> <@U07H6QLFPBM> <@U07H9CTPC9J>" >> $GITHUB_OUTPUT
1818
echo "reviewer_names=김지수, 고민지, 홍창현" >> $GITHUB_OUTPUT
19-
elif [[ $REPO_NAME == *"dev-be"* ]]; then
19+
elif [[ $TARGET_BRANCH == "dev-be" ]]; then
2020
echo "team=BE" >> $GITHUB_OUTPUT
2121
echo "reviewers=<@U07GSBPT9ST> <@U07H0978N14>" >> $GITHUB_OUTPUT
2222
echo "reviewer_names=김영길, 김준서" >> $GITHUB_OUTPUT
23-
else
24-
echo "team=Team" >> $GITHUB_OUTPUT
25-
echo "reviewers=@here" >> $GITHUB_OUTPUT
26-
echo "reviewer_names=전체" >> $GITHUB_OUTPUT
2723
fi
2824
25+
- name: Process PR title and body
26+
id: pr_process
27+
run: |
28+
# PR 제목 처리
29+
title='${{ github.event.pull_request.title }}'
30+
title="${title//'"'/'\\"'}"
31+
echo "title=${title}" >> $GITHUB_OUTPUT
32+
33+
# PR 내용 처리
34+
body='${{ github.event.pull_request.body }}'
35+
# Remove HTML comments and their content
36+
body=$(echo "$body" | sed 's/<!--.*-->//g')
37+
# Remove empty lines and special characters
38+
body=$(echo "$body" | grep -v '^$' | tr -d '\r')
39+
# Replace newlines with actual newlines in Slack message
40+
body=$(echo "$body" | tr '\n' ' ')
41+
echo "body=${body}" >> $GITHUB_OUTPUT
42+
2943
- name: Send Slack notification
3044
uses: 8398a7/action-slack@v3
3145
with:
@@ -57,14 +71,14 @@ jobs:
5771
"type": "section",
5872
"text": {
5973
"type": "mrkdwn",
60-
"text": "*PR 제목:*\n<${{ github.event.pull_request.html_url }}|${{ toJSON(github.event.pull_request.title) }}>"
74+
"text": "*PR 제목:*\n<${{ github.event.pull_request.html_url }}|${{ steps.pr_process.outputs.title }}>"
6175
}
6276
},
6377
{
6478
"type": "section",
6579
"text": {
6680
"type": "mrkdwn",
67-
"text": "*PR 설명:*\n${{ toJSON(github.event.pull_request.body) }}"
81+
"text": "*PR 설명:*\n${{ steps.pr_process.outputs.body }}"
6882
}
6983
},
7084
{

0 commit comments

Comments
 (0)