Hotfix: 로그인 validation 및 헤더 수정 #31
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
if (developers.length <= 1) { | |
core.setOutput('reviewers', developers.reviewers[0]); | |
core.setOutput('writer', prCreatorJson.name); | |
core.setOutput('pullRequestLink', prUrl); | |
} 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('reviewer1Name', JSON.stringify(randomReviewer1.name)); | |
core.setOutput('reviewer2Name', JSON.stringify(randomReviewer2.name)); | |
core.setOutput('reviewer1GithubName', randomReviewer1.githubName); | |
core.setOutput('reviewer2GithubName', randomReviewer2.githubName); | |
core.setOutput('writer', JSON.stringify(prCreatorJson.name)); | |
core.setOutput('pullRequestLink', JSON.stringify(prUrl)); | |
} | |
- 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 }}] | |
}' |