Skip to content

Commit

Permalink
Add workflow to auto label issues as WIP (#4251)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 authored Jan 5, 2023
1 parent 97360b6 commit df15640
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/label-wip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Auto Label WIP
on:
pull_request_target:
types:
- opened
- reopened
- edited
- closed

jobs:
check-linked-issues:
name: Check linked issues
runs-on: ubuntu-latest
outputs:
linked_issues: ${{ steps.issue-output.outputs.linked_issues }}
steps:
- name: Get issues
id: get-issues
uses: mondeja/pr-linked-issues-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set output
id: issue-output
run: echo "linked_issues=${{ steps.get-issues.outputs.issues }}" >> $GITHUB_OUTPUT

label-issues:
name: Label linked issues
runs-on: ubuntu-latest
needs: check-linked-issues
permissions: write-all
if: join(needs.check-linked-issues.outputs.linked_issues) != ''
steps:
- name: Label
uses: actions/github-script@v6
with:
script: |
const issues = "${{ needs.check-linked-issues.outputs.linked_issues }}".split(',')
for (const issue of issues) {
if ("${{ github.event.pull_request.state }}" == "open")
github.rest.issues.addLabels({
issue_number: issue,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["work-in-progress"]
})
else
github.rest.issues.removeLabel({
issue_number: issue,
owner: context.repo.owner,
repo: context.repo.repo,
name: ["work-in-progress"]
})
}

0 comments on commit df15640

Please sign in to comment.