diff options
-rw-r--r-- | .github/workflows/label-bug-fix.yml | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/.github/workflows/label-bug-fix.yml b/.github/workflows/label-bug-fix.yml index 37e2296a9..dae2980de 100644 --- a/.github/workflows/label-bug-fix.yml +++ b/.github/workflows/label-bug-fix.yml @@ -1,9 +1,10 @@ name: "Bug Fix label" on: pull_request_target: - types: [ opened,edited ] + types: [ opened, edited ] jobs: assign-label: + if: github.event.pull_request.state == 'open' # Condition to check if PR is open runs-on: ubuntu-latest permissions: issues: write @@ -19,25 +20,25 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN}} script: | if(process.env.TITLE.split(":")[0].toUpperCase().includes("FIX")){ - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: [process.env.LABEL] - }) + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [process.env.LABEL] + }) }else{ - const {data} = await github.rest.issues.listLabelsOnIssue({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, + const {data} = await github.rest.issues.listLabelsOnIssue({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }) + const filtered = data.filter(label => label.name == process.env.LABEL) + if(filtered.length == 1){ + github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: process.env.LABEL }) - const filtered = data.filter(label => label.name == process.env.LABEL) - if(filtered.length == 1){ - github.rest.issues.removeLabel({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - name: process.env.LABEL - }) - } + } } |