←  github actions

Views:

Creating labels on issues opened

We can also create a workflow which automates labelling issues as soon as they are opened. It also needs the Personal Access Token, here you can find the steps to create it The workflow for the same is as follows-

name: Issue Label

on:
  issues:
    types: [opened]

jobs:
  issue-label:
    runs-on: ubuntu-latest
    steps:
      - name: Adding Label to Issues Openend
        uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GH_ACTION_EXAMPLES_PAT }}
          script: |
            github.rest.issues.addLabels({
               issue_number: context.issue.number,
               owner: context.repo.owner,
               repo: context.repo.repo,
               labels: ['triage']
            })

Result

Following is the output for the above workflow-

create-label-result