Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/triage.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]"
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,
});
}