mirror of
https://github.com/glittercowboy/get-shit-done
synced 2026-04-25 17:25:23 +02:00
- actions/checkout v4.2.2 → v6.0.2 (pr-gate, auto-branch) - actions/github-script v7.0.1/v8 → v9.0.0 (all workflows) - actions/stale v9.0.0 → v10.2.0 Eliminates Node.js 20 deprecation warnings. Node 20 actions will be forced to Node 24 on June 2, 2026 and removed Sept 16, 2026. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
86 lines
2.7 KiB
YAML
86 lines
2.7 KiB
YAML
name: Auto-Branch from Issue Label
|
|
|
|
on:
|
|
issues:
|
|
types: [labeled]
|
|
|
|
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 main HEAD
|
|
const mainRef = 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: mainRef.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\`\`\``,
|
|
});
|