Skip to content

✨ feat: pr 이벤트 발생 시 슬랙에 노티 #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Notify Slack on PR Events
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 테스트


on:
pull_request:
types: [review_requested]
pull_request_review:
types: [submitted]

jobs:
notify:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "16"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 테스트 2


- name: Install dependencies
run: npm install

- name: Run Slack Notification Script
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GITHUB_EVENT_PATH: ${{ github.event_path }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
run: node script/sendMessageToSlack.js
114 changes: 114 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitejs/plugin-react": "^4.3.1",
"axios": "^1.7.2",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"fs": "^0.0.1-security",
"gitmoji-cli": "^9.4.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
Expand Down
6 changes: 6 additions & 0 deletions script/constant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable no-undef */
const users = {
bicochan: 'U07C75ZKHEX',
};

module.exports = users;
58 changes: 58 additions & 0 deletions script/createReviewSubmittedMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
const users = require('./constant');

function createReviewSubmittedMessage(event) {
const reviewer = event.review.user.login;
const reviewerId = users[reviewer];
const prOwner = event.pull_request.user.login;
const prOwnerId = users[prOwner];
const reviewUrl = event.review.html_url;

const blocks = [
{
type: 'rich_text',
elements: [
{
type: 'rich_text_section',
elements: [
{
type: 'user',
user_id: reviewerId,
},
{
type: 'text',
text: ' 님이 ',
},
{
type: 'user',
user_id: prOwnerId,
},
{
type: 'text',
text: ' 님의 PR에 ',
},
{
type: 'emoji',
name: 'link',
unicode: '1f517',
},
{
type: 'link',
url: reviewUrl,
text: '리뷰',
},
{
type: 'text',
text: '를 등록했어요.',
},
],
},
],
},
];

return { blocks };
}

module.exports = createReviewSubmittedMessage;
59 changes: 59 additions & 0 deletions script/createReviewerAssignedMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
const users = require('./constant');

function createReviewerAssignedMessage(event) {
const prOwner = event.pull_request.user.login;
const prOwnerId = users[prOwner];
const reviewers = event.pull_request.requested_reviewers.map(
(reviewer) => users[reviewer.login]
);
const prUrl = event.pull_request.html_url;

const blocks = [
{
type: 'rich_text',
elements: [
{
type: 'rich_text_section',
elements: [
{
type: 'user',
user_id: reviewers.join(', '),
},
{
type: 'text',
text: ' 님이 ',
},
{
type: 'user',
user_id: prOwnerId,
},
{
type: 'text',
text: ' 님의 ',
},
{
type: 'emoji',
name: 'link',
unicode: '1f517',
},
{
type: 'link',
url: prUrl,
text: 'PR',
},
{
type: 'text',
text: '에 리뷰어로 등록됐어요.',
},
],
},
],
},
];

return { blocks };
}

module.exports = createReviewerAssignedMessage;
Loading