epic(core): retire the core.cjs re-export spine — finish the ADR-857 decomposition #2089
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-Branch from Issue Label | |
| on: | |
| issues: | |
| types: [labeled] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| issues: write | |
| jobs: | |
| create-branch: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 2 | |
| if: >- | |
| contains(fromJSON('["bug", "enhancement", "priority: critical", "type: chore", "area: docs"]'), | |
| github.event.label.name) | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Create branch | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| script: | | |
| const label = context.payload.label.name; | |
| const issue = context.payload.issue; | |
| const number = issue.number; | |
| // Generate slug from title | |
| const slug = issue.title | |
| .toLowerCase() | |
| .replace(/[^a-z0-9]+/g, '-') | |
| .replace(/^-+|-+$/g, '') | |
| .substring(0, 40); | |
| // Map label to branch prefix | |
| const prefixMap = { | |
| 'bug': 'fix', | |
| 'enhancement': 'feat', | |
| 'priority: critical': 'fix', | |
| 'type: chore': 'chore', | |
| 'area: docs': 'docs', | |
| }; | |
| const prefix = prefixMap[label]; | |
| if (!prefix) return; | |
| // For priority: critical, use fix/critical-NNN-slug to avoid | |
| // colliding with the hotfix workflow's hotfix/X.Y.Z naming. | |
| const branch = label === 'priority: critical' | |
| ? `fix/critical-${number}-${slug}` | |
| : `${prefix}/${number}-${slug}`; | |
| // Check if branch already exists | |
| try { | |
| await github.rest.git.getRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: `heads/${branch}`, | |
| }); | |
| core.info(`Branch ${branch} already exists`); | |
| return; | |
| } catch (e) { | |
| if (e.status !== 404) throw e; | |
| } | |
| // Create branch from next HEAD (the integration branch under the | |
| // next-branch model). Fall back to main if next doesn't exist — | |
| // covers the brief transition window when this workflow was first | |
| // deployed and any legacy single-branch state. | |
| let baseRef; | |
| try { | |
| baseRef = await github.rest.git.getRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: 'heads/next', | |
| }); | |
| } catch (e) { | |
| if (e.status !== 404) throw e; | |
| baseRef = await github.rest.git.getRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: 'heads/main', | |
| }); | |
| } | |
| await github.rest.git.createRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: `refs/heads/${branch}`, | |
| sha: baseRef.data.object.sha, | |
| }); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: number, | |
| body: `Branch \`${branch}\` created.\n\n\`\`\`bash\ngit fetch origin && git checkout ${branch}\n\`\`\``, | |
| }); |