Feature: Tiered workshop repair levels (home workshop vs dealer) #28
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-add issues to project board | |
| permissions: | |
| contents: read | |
| issues: write | |
| on: | |
| issues: | |
| types: [opened] | |
| jobs: | |
| add-to-project: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Add issue to project board | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.PROJECT_TOKEN }} | |
| script: | | |
| const issueNodeId = context.payload.issue.node_id; | |
| const issueNumber = context.payload.issue.number; | |
| // Known project board IDs (FS25_UsedPlus project #3) | |
| const PROJECT_ID = 'PVT_kwHOAsLCS84BOmS4'; | |
| const STATUS_FIELD_ID = 'PVTSSF_lAHOAsLCS84BOmS4zg9QNkQ'; | |
| const TODO_OPTION_ID = 'f75ad846'; | |
| console.log(`Adding issue #${issueNumber} to project board...`); | |
| // Step 1: Add issue to project | |
| const addResult = await github.graphql(` | |
| mutation($projectId: ID!, $contentId: ID!) { | |
| addProjectV2ItemById(input: { | |
| projectId: $projectId | |
| contentId: $contentId | |
| }) { | |
| item { id } | |
| } | |
| } | |
| `, { | |
| projectId: PROJECT_ID, | |
| contentId: issueNodeId | |
| }); | |
| const itemId = addResult.addProjectV2ItemById.item.id; | |
| console.log(`Added issue #${issueNumber} to project (item: ${itemId})`); | |
| // Step 2: Set status to "Todo" | |
| await github.graphql(` | |
| mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) { | |
| updateProjectV2ItemFieldValue(input: { | |
| projectId: $projectId | |
| itemId: $itemId | |
| fieldId: $fieldId | |
| value: { singleSelectOptionId: $optionId } | |
| }) { | |
| projectV2Item { id } | |
| } | |
| } | |
| `, { | |
| projectId: PROJECT_ID, | |
| itemId: itemId, | |
| fieldId: STATUS_FIELD_ID, | |
| optionId: TODO_OPTION_ID | |
| }); | |
| console.log(`Set issue #${issueNumber} status to "Todo"`); | |
| // Step 3: Auto-label based on title/body content | |
| const title = (context.payload.issue.title || '').toLowerCase(); | |
| const body = (context.payload.issue.body || '').toLowerCase(); | |
| const text = title + ' ' + body; | |
| const labelsToAdd = []; | |
| if (/\b(bug|crash|freeze|error|broken|not working)\b/.test(text)) { | |
| labelsToAdd.push('bug'); | |
| } | |
| if (/\b(feature|request|suggestion|would be nice|add support)\b/.test(text)) { | |
| labelsToAdd.push('enhancement'); | |
| } | |
| if (/\b(question|how do|is it possible|can i|does it)\b/.test(text)) { | |
| labelsToAdd.push('question'); | |
| } | |
| // Only add labels that aren't already present (from templates) | |
| const existingLabels = (context.payload.issue.labels || []).map(l => l.name); | |
| const newLabels = labelsToAdd.filter(l => !existingLabels.includes(l)); | |
| if (newLabels.length > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| labels: newLabels | |
| }); | |
| console.log(`Added labels: ${newLabels.join(', ')}`); | |
| } else { | |
| console.log('No additional labels to add'); | |
| } |