From 912e22e22c9c176b49747b25a70a712591d3bbf1 Mon Sep 17 00:00:00 2001 From: "matej.vukosav" Date: Tue, 22 Oct 2024 15:08:09 +0200 Subject: [PATCH] chore: add on open label --- .github/workflows/new-issue-or-pr.yml | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/new-issue-or-pr.yml diff --git a/.github/workflows/new-issue-or-pr.yml b/.github/workflows/new-issue-or-pr.yml new file mode 100644 index 0000000..3dcd15f --- /dev/null +++ b/.github/workflows/new-issue-or-pr.yml @@ -0,0 +1,39 @@ +name: Label Issues and PRs on Open/Reopen + +on: + issues: + types: [opened, reopened] # Trigger when an issue is opened or reopened + pull_request: + types: [opened, reopened] # Trigger when a PR is opened or reopened + +jobs: + labelIssuePR: + name: Apply Label to Issues and PRs + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Add Label to Issue or PR + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + // Check if it's an issue or a PR + if (context.eventName === 'issues') { + // Add label to issue + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.issue.number, + labels: ['needs-team-review'] + }); + } else if (context.eventName === 'pull_request') { + // Add label to PR + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + labels: ['needs-team-review'] + }); + }