From e5028a525901188dff8943ffa64c5c3d6d77c5fa Mon Sep 17 00:00:00 2001 From: Alex Schwartz Date: Tue, 15 Oct 2024 09:10:24 -0500 Subject: [PATCH] Add an action to label draft PRs This took a bit of back-and-forth, since most people seem to use templates or scripts for this. Fortunately, though I learned a bit... - About the github CLI - About permissions for actions - About errors actions can throw I think I should be able to add a ready_for_review job to this same action to remove the "WIP" and put on "Ready for Review". Then, I wonder if I should look into scripts w/ TS for adding/removing labels? --- .github/workflows/label-draft-prs.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/label-draft-prs.yml diff --git a/.github/workflows/label-draft-prs.yml b/.github/workflows/label-draft-prs.yml new file mode 100644 index 0000000..e16867c --- /dev/null +++ b/.github/workflows/label-draft-prs.yml @@ -0,0 +1,18 @@ +name: Label Draft PRs + +on: + pull_request: + +jobs: + add_draft_label: + name: Add draft label to draft prs + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - run: gh pr edit $NUMBER --add-label "$LABEL" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.pull_request.number }} + LABEL: WIP