mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-07-12 19:00:58 +08:00
8943c1cbf4
Extends the existing label-pr workflow with an author allowlist that applies a core-team label. The label is auto-provisioned on first use so no manual repo setup is needed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
60 lines
2.5 KiB
YAML
60 lines
2.5 KiB
YAML
name: Label PR
|
|
|
|
# SECURITY: this workflow runs with write access to the base repo on fork PRs,
|
|
# because `pull_request_target` executes in the context of the base branch.
|
|
# Keep it metadata-only — do NOT add actions/checkout or any step that
|
|
# executes PR-supplied content (install scripts, build commands, etc.).
|
|
# See https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, edited]
|
|
|
|
jobs:
|
|
label:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
pull-requests: write
|
|
issues: write # createLabel — auto-provisions the core-team label
|
|
steps:
|
|
- uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const body = context.payload.pull_request.body || '';
|
|
const labels = [];
|
|
|
|
if (body.includes('[x] **Feature skill**')) { labels.push('PR: Skill'); labels.push('PR: Feature'); }
|
|
else if (body.includes('[x] **Utility skill**')) labels.push('PR: Skill');
|
|
else if (body.includes('[x] **Operational/container skill**')) labels.push('PR: Skill');
|
|
else if (body.includes('[x] **Fix**')) labels.push('PR: Fix');
|
|
else if (body.includes('[x] **Simplification**')) labels.push('PR: Refactor');
|
|
else if (body.includes('[x] **Documentation**')) labels.push('PR: Docs');
|
|
|
|
if (body.includes('contributing-guide: v1')) labels.push('follows-guidelines');
|
|
|
|
// Lowercase GitHub logins; keep in sync with the core team roster.
|
|
const CORE_TEAM = ['gavrielc', 'koshkoshinsk', 'glifocat', 'gabi-simons', 'omri-maya', 'amit-shafnir', 'moshe-nanoco'];
|
|
const author = context.payload.pull_request.user.login.toLowerCase();
|
|
if (CORE_TEAM.includes(author)) {
|
|
labels.push('core-team');
|
|
try {
|
|
await github.rest.issues.createLabel({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
name: 'core-team',
|
|
color: '1D76DB',
|
|
description: 'PR opened by a core team member',
|
|
});
|
|
} catch (e) {
|
|
if (e.status !== 422) throw e; // 422: label already exists
|
|
}
|
|
}
|
|
|
|
if (labels.length > 0) {
|
|
await github.rest.issues.addLabels({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.payload.pull_request.number,
|
|
labels,
|
|
});
|
|
}
|