mirror of
https://github.com/lightseekorg/tokenspeed.git
synced 2026-12-04 10:26:50 +08:00
Older PR branches do not contain the attribution scripts introduced on the base branch, so checking out only the PR head makes the new CI fail before it can validate emails. Use the normal PR merge checkout to make those scripts available while keeping attribution checks bound to the original PR head. Validated the reported missing-file failure against the old PR head and a passing run against its merge revision; all four attribution tests and pre-commit pass. Signed-off-by: lightseek-bot <243258330+lightseek-bot@users.noreply.github.com>
63 lines
2.1 KiB
YAML
63 lines
2.1 KiB
YAML
name: PR Commit Trailers
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, edited, synchronize, reopened]
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
|
|
concurrency:
|
|
group: pr-commit-trailers-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
commit-trailers:
|
|
name: Commit trailers
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
# Use the PR merge commit so older branches inherit the check scripts.
|
|
# The checks below still inspect the original PR head commits.
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Check commit co-authors
|
|
env:
|
|
BASE_REF: ${{ github.event.pull_request.base.ref }}
|
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
run: |
|
|
set -euo pipefail
|
|
commits="$RUNNER_TEMP/pr-commits.txt"
|
|
message="$RUNNER_TEMP/pr-commit-message.txt"
|
|
forbidden='^[[:space:]]*Co-authored-by:.*(Codex|Claude[[:space:]]+Code|noreply@anthropic\.com|\bCursor\b|\bCopilot\b)'
|
|
git rev-list "refs/remotes/origin/$BASE_REF..$HEAD_SHA" > "$commits"
|
|
|
|
failed=false
|
|
while IFS= read -r commit; do
|
|
git log -1 --format=%B "$commit" > "$message"
|
|
if grep -qiE "$forbidden" "$message"; then
|
|
echo "::error::Commit $commit has a Co-authored-by trailer blocked by the attribution policy."
|
|
failed=true
|
|
fi
|
|
done < "$commits"
|
|
|
|
if [[ "$failed" == true ]]; then
|
|
echo "::error::Amend the listed commits to remove these Co-authored-by trailers, then push the updated branch."
|
|
exit 1
|
|
fi
|
|
echo "Commit trailers comply with the attribution policy."
|
|
|
|
- name: Test commit attribution check
|
|
run: node --test .github/scripts/check-commit-attribution.test.js
|
|
|
|
- name: Check commit email attribution
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const check = require('./.github/scripts/check-commit-attribution.js');
|
|
await check({ github, core, context });
|