[FEATURE] sample #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto Update Issue Title | |
| on: | |
| issues: | |
| types: [opened, edited] | |
| permissions: | |
| issues: write | |
| jobs: | |
| update-title: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Update title based on Issue Type | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const issue = context.payload.issue; | |
| const body = issue.body; | |
| let prefix = "[TASK]"; | |
| if (body.includes("Bug")) prefix = "[BUG]"; | |
| else if (body.includes("Feature")) prefix = "[FEATURE]"; | |
| else if (body.includes("Documentation")) prefix = "[DOC]"; | |
| else if (body.includes("Task")) prefix = "[TASK]"; | |
| // Remove existing prefix if present | |
| const cleanTitle = issue.title.replace(/^\[.*?\]\s*/, ""); | |
| const newTitle = `${prefix} ${cleanTitle}`; | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issue.number, | |
| title: newTitle | |
| }); |