Skip to content

[hotfix] https 삭제 #28

[hotfix] https 삭제

[hotfix] https 삭제 #28

Workflow file for this run

name: "Pick Reviewer"
on:
pull_request:
types: opened
jobs:
pick-random-reviewer:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Pick random reviewer
id: pick_random_reviewer
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const developers = JSON.parse(fs.readFileSync(`${{ github.workspace }}/.github/workflows/reviewer.json`));
const prCreator = context.payload.pull_request.user.login;
const prUrl = context.payload.pull_request.html_url;
const prCreatorJson = developers.reviewers.find(person => person.githubName === prCreator);
//PrCreator가 reviewer에 등록되지 않은 사람인 경우
if (!prCreatorJson) {
const reviewerArr = developers.reviewers;
const randomReviewer1 = reviewerArr[Math.floor(Math.random() * reviewerArr.length)];
const randomReviewer2 = reviewerArr[Math.floor(Math.random() * reviewerArr.length)];
core.setOutput('writer', JSON.stringify(prCreator));
} else {
const candidateInternalReviewers = developers.reviewers.filter(person => person.team === prCreatorJson.team && person.githubName !== prCreator);
const candidateExternalReviewers = developers.reviewers.filter(person => person.team !== prCreatorJson.team);
const randomReviewer1 = candidateInternalReviewers[Math.floor(Math.random() * candidateInternalReviewers.length)];
const randomReviewer2 = candidateExternalReviewers[Math.floor(Math.random() * candidateExternalReviewers.length)];
core.setOutput('writer', JSON.stringify(prCreatorJson.name));
}
core.setOutput('pullRequestLink', JSON.stringify(prUrl));
core.setOutput('reviewer1Name', JSON.stringify(randomReviewer1.name));
core.setOutput('reviewer2Name', JSON.stringify(randomReviewer2.name));
core.setOutput('reviewer1GithubName', randomReviewer1.githubName);
core.setOutput('reviewer2GithubName', randomReviewer2.githubName);
- name: test valiable
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: console.log(${{ steps.pick_random_reviewer.outputs.reviewer1Name }})
- name: Add Reviewers
uses: madrapps/add-reviewers@v1
with:
reviewers: ${{ steps.pick_random_reviewer.outputs.reviewer1GithubName }},${{ steps.pick_random_reviewer.outputs.reviewer2GithubName }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Send Slack Trigger
run: |
curl -X POST https://api-slack.internal.bcsdlab.com/api/review-request/frontend \
-H 'Content-Type: application/json' \
-d '{
"pullRequestLink": ${{ steps.pick_random_reviewer.outputs.pullRequestLink }},
"writer": ${{ steps.pick_random_reviewer.outputs.writer }},
"reviewers": [${{ steps.pick_random_reviewer.outputs.reviewer1Name }}, ${{ steps.pick_random_reviewer.outputs.reviewer2Name }}]
}'