mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
Bumps the github-actions group with 3 updates: [docker/build-push-action](https://github.com/docker/build-push-action), [actions/github-script](https://github.com/actions/github-script) and [pnpm/action-setup](https://github.com/pnpm/action-setup). Updates `docker/build-push-action` from 7.0.0 to 7.1.0 - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v7.0.0...v7.1.0) Updates `actions/github-script` from 8 to 9 - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v8...v9) Updates `pnpm/action-setup` from 5.0.0 to 6.0.0 - [Release notes](https://github.com/pnpm/action-setup/releases) - [Commits](https://github.com/pnpm/action-setup/compare/v5.0.0...v6.0.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-version: 7.1.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions - dependency-name: actions/github-script dependency-version: '9' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: pnpm/action-setup dependency-version: 6.0.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
55 lines
1.8 KiB
YAML
55 lines
1.8 KiB
YAML
name: PR Title Check
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, edited, reopened, synchronize]
|
|
|
|
jobs:
|
|
title-format:
|
|
if: github.repository == 'AstrBotDevs/AstrBot'
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
pull-requests: write
|
|
issues: write
|
|
|
|
steps:
|
|
- name: Validate PR title
|
|
uses: actions/github-script@v9
|
|
with:
|
|
script: |
|
|
const title = (context.payload.pull_request.title || "").trim();
|
|
// allow only:
|
|
// feat: xxx
|
|
// feat(scope): xxx
|
|
const pattern = /^(feat)(\([a-z0-9-]+\))?:\s.+$/i;
|
|
const isValid = pattern.test(title);
|
|
const isSameRepo =
|
|
context.payload.pull_request.head.repo.full_name === context.payload.repository.full_name;
|
|
|
|
if (!isValid) {
|
|
if (isSameRepo) {
|
|
try {
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.payload.pull_request.number,
|
|
body: [
|
|
"⚠️ PR title format check failed.",
|
|
"Required formats:",
|
|
"- `feat: xxx`",
|
|
"- `feat(scope): xxx`",
|
|
"Please update your PR title and push again."
|
|
].join("\n")
|
|
});
|
|
} catch (e) {
|
|
core.warning(`Failed to post PR title comment: ${e.message}`);
|
|
}
|
|
} else {
|
|
core.warning("Fork PR: comment permission is restricted; skip posting review comment.");
|
|
}
|
|
}
|
|
|
|
if (!isValid) {
|
|
core.setFailed("Invalid PR title. Expected format: feat: xxx or feat(scope): xxx.");
|
|
}
|