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
31 changes: 24 additions & 7 deletions .github/workflows/labeler-approve.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: "Labels: Approve"

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

permissions: write-all
pull_request:
types: [edited]

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
uses: actions/github-script@v6
with:
github-token: ${{ secrets.URPRICE_PAT }}
script: |
console.log('L:A verby 1502 23022025');
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -26,3 +25,21 @@ jobs:
const approvedReviews = reviews.filter(review => review.state === 'APPROVED').length;

return approvedReviews >= requiredApprovals;
- name: rm labels
if: steps.check_approvals.outputs.result == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.URPRICE_PAT }}
script: |
const labelsToRemove = ['Status: Needs Review', 'Status: Awaiting Changes'];
const currentLabels = context.payload.pull_request.labels.map(label => label.name);
for (const label of labelsToRemove) {
if (currentLabels.includes(label)) {
await github.request('DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}', {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: label,
});
}
}
Loading