Skip to content

Commit

Permalink
add actual label-pr code
Browse files Browse the repository at this point in the history
  • Loading branch information
sanidhyas3s authored Aug 28, 2024
1 parent eae4377 commit f84bfa6
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/label-prs.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
name: Auto Label PRs
name: Label PRs "waiting for review/update"

permissions:
contents: read
pull-requests: write


on:
pull_request:
types: [review_requested, synchronize, reopened]
types: [review_requested, review_requested]
pull_request_review:
types: [submitted]
issue_comment:
types: [created]

jobs:
update-labels:
manage-labels:
runs-on: ubuntu-latest
steps:
- name: Remove 'waiting for changes' and Add 'waiting for review' label
uses: actions-ecosystem/action-add-labels@v1
- name: Set up GitHub CLI
uses: cli/cli@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: waiting for review

- name: Remove 'waiting for changes' label if exists

- name: Add 'waiting for review' label if review is requested
if: github.event_name == 'pull_request' && github.event.action == 'review_requested'
run: |
gh pr edit ${{ github.event.pull_request.number }} --add-label "waiting for review"
- name: Add 'waiting for update' label if changes are requested
if: github.event_name == 'pull_request_review' && github.event.review.state == 'changes_requested'
run: |
gh pr edit ${{ github.event.pull_request.number }} --add-label "waiting for update"
- name: Remove 'waiting for update' label if a comment is made by the author
if: github.event_name == 'issue_comment'
run: |
if gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name' | grep -q 'waiting for changes'; then
gh pr edit ${{ github.event.pull_request.number }} --remove-label "waiting for changes"
fi
comment_author=$(gh pr view ${{ github.event.issue.number }} --json author --jq '.author.login')
if [ "$comment_author" == "${{ github.actor }}" ]; then
gh pr edit ${{ github.event.issue.number }} --remove-label "waiting for update"
fi

0 comments on commit f84bfa6

Please sign in to comment.