[CHORE]: Update Issue Templates #12
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: "Issue Verification and Automation Pipeline" | |
| on: | |
| issues: | |
| types: [opened, edited] | |
| issue_comment: | |
| types: [created] | |
| workflow_dispatch: | |
| jobs: | |
| process-issue: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| steps: | |
| # Step 1: Validate Title Formats (Only runs on issue creation or modification) | |
| - name: Verify Issue Title Format | |
| if: github.event_name == 'issues' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const title = context.payload.issue.title; | |
| const titleRegex = /^\[(BUG|FEATURE|CHORE|DOCS|PERF)\]:\s.+$/; | |
| if (!titleRegex.test(title)) { | |
| core.setFailed(`Validation Failed: Title "${title}" does not follow the '[ISSUE_TYPE]: ' naming convention.`); | |
| } | |
| # Step 2: Validate Description Substance and Checkbox Integrity (Only runs on issues) | |
| - name: Verify Issue Body and Checklists | |
| if: github.event_name == 'issues' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const body = context.payload.issue.body; | |
| if (!body || body.trim().length < 20) { | |
| core.setFailed("Validation Failed: The issue body description is missing or too brief (minimum 20 characters)."); | |
| return; | |
| } | |
| const uncheckedRegex = /-\s*\[\s*\]/g; | |
| if (uncheckedRegex.test(body)) { | |
| core.setFailed("Validation Failed: The introduction checklist contains uncompleted requirements. Mark items with an [x]."); | |
| } | |
| # Step 3: Automated Assignment Handling (Only runs on new comments) | |
| - name: Handle Automated Issue Assignment | |
| if: github.event_name == 'issue_comment' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const issueNumber = context.payload.issue.number; | |
| const commentBody = context.payload.comment.body.trim().toLowerCase(); | |
| const commenter = context.payload.comment.user.login; | |
| // Define targeted keyword phrases trigger paths (e.g., "assign me", "claim issue") | |
| const assignmentKeywords = ["assign me", "claim issue"]; | |
| const isMatch = assignmentKeywords.some(keyword => commentBody.includes(keyword)); | |
| if (!isMatch) { | |
| console.log("Comment does not contain explicit assignment trigger phrasing. Skipping execution."); | |
| return; | |
| } | |
| // Fetch the fresh status profile of the issue to avoid race conditions | |
| const { data: issue } = await github.rest.issues.get({ | |
| owner, | |
| repo, | |
| issue_number: issueNumber, | |
| }); | |
| // Check if there is an existing assignee on record | |
| if (issue.assignees && issue.assignees.length > 0) { | |
| console.log(`Assignment Aborted: Issue #${issueNumber} is already assigned to ${issue.assignees[0].login}.`); | |
| return; | |
| } | |
| // Assign the issue to the commenter | |
| try { | |
| await github.rest.issues.addAssignees({ | |
| owner, | |
| repo, | |
| issue_number: issueNumber, | |
| assignees: [commenter], | |
| }); | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: issueNumber, | |
| body: `@${commenter}, this issue has been successfully assigned to you. You may begin working on your PR implementation.` | |
| }); | |
| console.log(`Successfully assigned issue #${issueNumber} to user: ${commenter}`); | |
| } catch (error) { | |
| core.setFailed(`Automated assignment operations failed: ${error.message}`); | |
| } |