diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 89d8088..cc0447c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -5,6 +5,7 @@ We are using [GitHub Actions](https://github.com/features/actions) as a continuo For details, take a look at the following workflow configuration files: - [`workflows/integrate.yaml`](workflows/integrate.yaml) +- [`workflows/triage.yaml`](workflows/triage.yaml) ## Coding Standards diff --git a/.github/workflows/triage.yaml b/.github/workflows/triage.yaml new file mode 100644 index 0000000..1b7d92b --- /dev/null +++ b/.github/workflows/triage.yaml @@ -0,0 +1,45 @@ +# https://docs.github.com/en/actions + +name: "Triage" + +on: # yamllint disable-line rule:truthy + pull_request: + types: + - "opened" + +jobs: + label: + name: "Label" + + runs-on: "ubuntu-latest" + + steps: + - name: "Add labels based on branch name" + uses: "actions/github-script@v2.0.0" + with: + github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}" + script: | + const branchPrefixLabels = { + feature: "enhancement", + fix: "bug", + } + + const pullRequest = context.payload.pull_request + const repository = context.repo + + const branchName = pullRequest.head.ref + + const matches = branchName.match(new RegExp('^([^/]+)\/')); + + if (matches instanceof Array && branchPrefixLabels.hasOwnProperty(matches[1])) { + const label = branchPrefixLabels[matches[1]] + + github.issues.addLabels({ + issue_number: pullRequest.number, + labels: [ + label + ], + owner: repository.owner, + repo: repository.repo, + }); + }