Skip to content
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

workflow approver #2616

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
15 changes: 10 additions & 5 deletions .github/workflows/labeler-approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

on:
pull_request_review:
types: [submitted, edited, dismissed]
types: [submitted]

permissions: write-all

jobs:
remove_label:
runs-on: ubuntu-latest
if: github.event.review.state == 'approved'
steps:
- name: check all revs
- name: check all reviewers
id: check_approvals
uses: actions/github-script@v7
with:
script: |
console.log('L:A verby 2255 22022025');
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -24,7 +24,11 @@ jobs:

const requiredApprovals = context.payload.pull_request.requested_reviewers.length;
const approvedReviews = reviews.filter(review => review.state === 'APPROVED').length;

if (approvedReviews >= requiredApprovals) {
console.log('All Reviews Submitted');
} else {
console.log('Not All Reviews Submitted');
}
return approvedReviews >= requiredApprovals;

- name: rm labels
Expand All @@ -35,9 +39,10 @@ jobs:
script: |
const labelsToRemove = ['Status: Needs Review', 'Status: Awaiting Changes'];
const currentLabels = context.payload.pull_request.labels.map(label => label.name);

console.log('Current Labels:', currentLabels);
for (const label of labelsToRemove) {
if (currentLabels.includes(label)) {
console.log(`Removing label: ${label}`)
await github.request("DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}", {
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
Loading