jj/.github/workflows/pr.yml
dependabot[bot] 0762327b50 github: bump the github-dependencies group with 5 updates
Bumps the github-dependencies group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4.6.2` | `5.0.0` |
| [taiki-e/install-action](https://github.com/taiki-e/install-action) | `2.62.33` | `2.62.38` |
| [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) | `7.1.1` | `7.1.2` |
| [github/codeql-action](https://github.com/github/codeql-action) | `4.30.9` | `4.31.0` |
| [actions/github-script](https://github.com/actions/github-script) | `7` | `8` |


Updates `actions/upload-artifact` from 4.6.2 to 5.0.0
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](ea165f8d65...330a01c490)

Updates `taiki-e/install-action` from 2.62.33 to 2.62.38
- [Release notes](https://github.com/taiki-e/install-action/releases)
- [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md)
- [Commits](e43a5023a7...c5b1b6f479)

Updates `astral-sh/setup-uv` from 7.1.1 to 7.1.2
- [Release notes](https://github.com/astral-sh/setup-uv/releases)
- [Commits](2ddd2b9cb3...85856786d1)

Updates `github/codeql-action` from 4.30.9 to 4.31.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](16140ae1a1...4e94bd11f7)

Updates `actions/github-script` from 7 to 8
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v7...v8)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-dependencies
- dependency-name: taiki-e/install-action
  dependency-version: 2.62.38
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
- dependency-name: astral-sh/setup-uv
  dependency-version: 7.1.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
- dependency-name: github/codeql-action
  dependency-version: 4.31.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-dependencies
- dependency-name: actions/github-script
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-27 17:35:47 +00:00

79 lines
3 KiB
YAML

name: Validate pull request
on:
pull_request_target:
types: [opened, synchronize, edited]
permissions:
contents: read
pull-requests: write
jobs:
check-pr:
name: Commit subject lines
runs-on: ubuntu-latest
steps:
- name: Run validation script
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pullRequest = {
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
};
const { data: commits } = await github.rest.pulls.listCommits(pullRequest);
const { data: reviews } = await github.rest.pulls.listReviews(pullRequest);
// Get latest review by `github-actions[bot]`
const githubActionsBot = 41898282;
const latestReview = reviews
.filter(r => r.user.id === githubActionsBot)
.at(-1);
// Ensure commit subject lines are in the form `area or areas: Description`
const subjectLineFormat = /^.+:\s.+$/;
const badCommits = commits
.map(c => [c.sha.slice(0, 8), c.commit.message.split('\n')[0]])
.filter(([_, s]) => !subjectLineFormat.test(s))
.map(([sha, title]) => `- ${sha}: ${title}`);
if (badCommits.length > 0) {
// One or commits are bad, make sure changes are requested.
const body = 'The following commits do not follow our format for subject lines:\n\n'
+ `${badCommits.join('\n')}\n\nCommits should have a subject line following the `
+ 'format `<topic>: <description>`. Please review the [commit guidelines]'
+ '(https://jj-vcs.github.io/jj/prerelease/contributing/#commit-guidelines) for '
+ 'more information.';
if (latestReview?.state !== 'CHANGES_REQUESTED') {
await github.rest.pulls.createReview({
event: 'REQUEST_CHANGES',
...pullRequest,
body,
});
}
else {
await github.rest.pulls.updateReview({
review_id: latestReview.id,
...pullRequest,
body,
});
}
await core.setFailed('One or more commits were not formatted correctly.');
}
else {
// All commits are formatted correctly, dismiss any change requests.
if (latestReview && latestReview.state === 'CHANGES_REQUESTED') {
await github.rest.pulls.dismissReview({
message: 'All commits are now correctly formatted. Thank you for your contribution!',
review_id: latestReview.id,
...pullRequest,
});
}
console.log('All commits were correctly formatted.');
}