Skip to content

Commit

Permalink
Added workflow for autolabeling issues and PRs #11 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
onl1ner authored Dec 31, 2023
1 parent 3f7a0fe commit c54dd3a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/actions/label-generator/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [[ "$1" == *"feature"* ]]; then
echo "feature"
elif [[ "$1" == *"bug"* ]]; then
echo "bug"
fi
16 changes: 16 additions & 0 deletions .github/actions/label-generator/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Label generator'
description: 'Generates label based on the given value'
inputs:
value:
description: 'Value to label'
required: true
outputs:
label:
description: 'Label name'
value: ${{ steps.main.outputs.label }}
runs:
using: "composite"
steps:
- id: main
run: echo "label=$(bash ${{ github.action_path }}/action.sh ${{ inputs.value }})" >> $GITHUB_OUTPUT
shell: bash
41 changes: 41 additions & 0 deletions .github/workflows/autolabeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 'Autolabeling'

on:
issues:
types:
- opened
- edited
pull_request_target:
types:
- opened
- edited

jobs:
label:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- id: label-generator
uses: ./.github/actions/label-generator
with:
value: ${{ github.event.issue && github.event.issue.title || github.event.pull_request.head.ref }}
- name: Apply label on Issue
if: github.event.issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
URL: ${{ github.event.issue.html_url }}
LABEL: ${{ steps.label-generator.outputs.label }}
run: |
gh issue edit "$URL" --add-label "$LABEL"
- name: Apply label on PR
if: github.event.pull_request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
URL: ${{ github.event.pull_request.html_url }}
LABEL: ${{ steps.label-generator.outputs.label }}
run: |
gh pr edit "$URL" --add-label "$LABEL"

0 comments on commit c54dd3a

Please sign in to comment.