Auto labels and draft #4
Workflow file for this run
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: PR Automation | |
on: | |
pull_request: | |
types: | |
- opened | |
- ready_for_review | |
- converted_to_draft | |
permissions: | |
pull-requests: write | |
contents: read | |
jobs: | |
pr-automation: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Mark PR as Draft | |
if: github.event.action == 'opened' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.pulls.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
draft: true | |
}) | |
- name: Add WIP Label on Draft | |
if: github.event.action == 'converted_to_draft' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
labels: ['WIP'] | |
}) | |
- name: Remove WIP and Add Ready Label | |
if: github.event.action == 'ready_for_review' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
// Remove WIP label | |
try { | |
await github.rest.issues.removeLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
name: 'WIP' | |
}); | |
} catch (error) { | |
console.log('WIP label not found, continuing...'); | |
} | |
// Add ready-for-review label | |
github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
labels: ['ready-for-review'] | |
}) |