feat: ํํด ์ ๋ค๋ก๊ฐ๊ธฐ ๋ฒํผ ์ ๊ฑฐ & ๋ชฉํ ๋ฏธํฐ 2000, 4000 ์ถ๊ฐ #1391
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: 'Review Status Labeling' | |
on: | |
pull_request: | |
types: [opened, edited, reopened, ready_for_review] | |
pull_request_review: | |
types: [submitted, edited] | |
jobs: | |
labeler: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v2 | |
- name: Count Approvals | |
id: count_approvals | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.ACTIONS_TOKEN }} | |
script: | | |
const reviewsResponse = await github.rest.pulls.listReviews({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}); | |
const approvedReviews = reviewsResponse.data.filter(review => review.state === 'APPROVED'); | |
return approvedReviews.length; | |
- name: Get Labels | |
id: get_labels | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.ACTIONS_TOKEN }} | |
script: | | |
const labelsResponse = await github.rest.issues.listLabelsOnIssue({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}); | |
return labelsResponse.data.map(label => label.name); | |
- name: Apply Labels | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.ACTIONS_TOKEN }} | |
script: | | |
const labelNameList = ${{ steps.get_labels.outputs.result }}; | |
if (${{ steps.count_approvals.outputs.result }} === 0) { | |
if (labelNameList.includes('Approved ๐') === true) { | |
await github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'Approved ๐' | |
}); | |
} | |
if (labelNameList.length === 0 || labelNameList.includes('Review Plz๐') === false) { | |
await github.rest.issues.addLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: ['Review Plz๐'] | |
}); | |
} | |
} else { | |
if (labelNameList.includes('Review Plz๐') === true) { | |
await github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'Review Plz๐' | |
}); | |
} | |
if (labelNameList.includes('Approved ๐') === false) { | |
await github.rest.issues.addLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: ['Approved ๐'] | |
}); | |
} | |
} |