Skip to content

Commit

Permalink
Create label_pr
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarne authored Apr 10, 2024
1 parent 1aa0df4 commit 5cbada6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/label_pr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Label PR based on Branch Name

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
label_pr:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Get Branch Name
id: branch_name
run: echo "::set-output name=name::$(echo $GITHUB_REF | cut -d'/' -f 3)"

- name: Label PR
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const branchName = '${{ steps.branch_name.outputs.name }}';
const prefix = branchName.split('-')[0];
const labelsToAdd = [prefix];
await github.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labelsToAdd
});

0 comments on commit 5cbada6

Please sign in to comment.