Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,4 @@
# post_check rule 'Enforce branch naming convention (internal)' was removed without replacement (no success_conditions or neutral_conditions to migrate)
pull_request_rules:
- name: Enforce branch naming convention (internal)
description: Auto-close PRs from internal branches that don't follow naming convention
conditions:
- -head~=^[a-z0-9]([a-z0-9._-]*[a-z0-9])?(/[a-z0-9._-]+)+$
- head != main
- head-repo-full-name = lightseekorg/smg
actions:
comment:
message: |
Hi @{{author}}, the branch `{{head}}` does not follow our naming convention.

Please use one of the following formats:
- `<type>/<description>` — e.g. `feat/add-auth`, `fix/null-pointer`, `dependabot/cargo/pyo3-0.28.1`
- `<username>/<description>` — e.g. `changsu/fix-routing`

Allowed types: `feat`, `fix`, `chore`, `docs`, `refactor`, `test`, `ci`, `perf`

> **Note:** PRs with non-conforming branch names **will be auto-closed**. Please follow the naming convention for all branches.
close:
message: |
Closing this PR because the branch name `{{head}}` does not follow the naming convention.

To fix this, please rename your branch locally, push the new branch, and open a new PR:
```bash
git branch -m <new-branch-name>
git push origin -u <new-branch-name>
```

- name: Comment on DCO check failure
description: Post fix instructions when DCO sign-off is missing
conditions:
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/pr-naming-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,52 @@ concurrency:
cancel-in-progress: true

jobs:
branch-naming:
name: Branch Naming Convention
runs-on: ubuntu-latest
# Only enforce on internal PRs, not forks
if: github.event.pull_request.head.repo.full_name == 'lightseekorg/smg' && github.head_ref != 'main'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent fork PR check noise at workflow trigger level

Using a job-level if here does not make the check invisible on fork PRs: the workflow still runs on every pull_request, and branch-naming becomes a skipped check run rather than disappearing. GitHub documents that skipped jobs are reported as successful status checks, so this still adds check noise on forks and does not achieve the stated “no skipped check” behavior.

Useful? React with 👍 / 👎.

permissions:
contents: read
pull-requests: write
steps:
- name: Validate branch name
env:
BRANCH: ${{ github.head_ref }}
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
run: |
REGEX='^[a-z0-9]([a-z0-9._-]*[a-z0-9])?(/[a-z0-9._-]+)+$'

if [[ "$BRANCH" =~ $REGEX ]]; then
echo "✅ Branch name is valid: '$BRANCH'"
exit 0
fi

# Post comment and close the PR
gh pr comment "$PR_NUMBER" \
--repo "${{ github.repository }}" \
--body "Hi @${PR_AUTHOR}, the branch \`${BRANCH}\` does not follow our naming convention.

Please use one of the following formats:
- \`<type>/<description>\` — e.g. \`feat/add-auth\`, \`fix/null-pointer\`, \`dependabot/cargo/pyo3-0.28.1\`
- \`<username>/<description>\` — e.g. \`changsu/fix-routing\`

Allowed types: \`feat\`, \`fix\`, \`chore\`, \`docs\`, \`refactor\`, \`test\`, \`ci\`, \`perf\`

To fix, rename your branch locally, push the new branch, and open a new PR:
\`\`\`bash
git branch -m <new-branch-name>
git push origin -u <new-branch-name>
\`\`\`"

gh pr close "$PR_NUMBER" \
--repo "${{ github.repository }}" \
--comment "Closing this PR because the branch name \`${BRANCH}\` does not follow the naming convention."

exit 1

pr-validation:
name: PR Title & Commit Messages
runs-on: ubuntu-latest
Expand Down
Loading