mirror of
https://github.com/alirezarezvani/claude-skills.git
synced 2026-08-28 04:24:58 +00:00
- enforce-pr-target.yml: drop the no-op split/trim/join on the comment body (array join already produces the final text) - ci-quality-gate.yml: safety findings now emit a workflow warning instead of being silently absorbed by '|| true' - check_paths.py: fnmatch import hoisted to module level - smoke_scripts.py: stale exception entries now fail the gate (exit 3) so scripts/smoke_exceptions.txt stays tidy https://claude.ai/code/session_019AJddAL1NADWMXsy1qNPQF
75 lines
2.8 KiB
YAML
75 lines
2.8 KiB
YAML
---
|
|
name: Enforce PR Target Branch
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, edited, ready_for_review]
|
|
branches: [main]
|
|
|
|
permissions:
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
check-target:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Block PRs targeting main (only dev -> main promotion allowed)
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const pr = context.payload.pull_request;
|
|
const author = pr.user.login;
|
|
const headRef = pr.head.ref;
|
|
const sameRepo = pr.head.repo.full_name === context.payload.repository.full_name;
|
|
|
|
// HARD RULE (CLAUDE.md > Git Workflow): main only receives
|
|
// dev -> main promotion PRs. Branch-based, not author-based —
|
|
// maintainers are not exempt.
|
|
if (sameRepo && headRef === 'dev') {
|
|
console.log(`✅ dev -> main promotion PR — allowed.`);
|
|
return;
|
|
}
|
|
|
|
// Maintainers: fail the check and explain, but don't auto-close
|
|
// (avoids nuking intentional work; retarget instead).
|
|
const maintainers = ['alirezarezvani'];
|
|
const isMaintainer = maintainers.includes(author);
|
|
|
|
const nextStep = isMaintainer
|
|
? 'This check will re-run automatically once the base branch is changed.'
|
|
: 'This PR has been closed automatically; reopen it after retargeting, ' +
|
|
'or open a new PR against `dev`.';
|
|
|
|
const message = [
|
|
`👋 Hi @${author}, thanks for your contribution!`,
|
|
'',
|
|
'All PRs must target the `dev` branch, not `main`. The `main` branch',
|
|
'only receives `dev -> main` promotion PRs (see CLAUDE.md > Git Workflow).',
|
|
'',
|
|
'**How to fix:** click "Edit" at the top right of this PR and change',
|
|
'the base branch to `dev`.',
|
|
'',
|
|
nextStep,
|
|
'',
|
|
'See our [Contributing Guide]' +
|
|
'(https://github.com/alirezarezvani/claude-skills/blob/dev/CONTRIBUTING.md)' +
|
|
' for details.',
|
|
].join('\n');
|
|
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: pr.number,
|
|
body: message,
|
|
});
|
|
|
|
if (!isMaintainer) {
|
|
await github.rest.pulls.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: pr.number,
|
|
state: 'closed',
|
|
});
|
|
}
|
|
|
|
core.setFailed(`PR #${pr.number} targets main from '${headRef}' (not dev). ${isMaintainer ? 'Retarget to dev.' : 'Closed automatically.'}`);
|