|
| 1 | +name: Check signed commits in PR |
| 2 | +on: pull_request_target |
| 3 | + |
| 4 | +concurrency: |
| 5 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} |
| 6 | + cancel-in-progress: true |
| 7 | + |
| 8 | +jobs: |
| 9 | + check-signed-commits: |
| 10 | + name: Check signed commits in PR |
| 11 | + runs-on: ubuntu-latest |
| 12 | + timeout-minutes: 10 |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + pull-requests: write |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 19 | + with: |
| 20 | + ref: ${{ github.event.pull_request.head.sha }} |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Check for bot commits |
| 24 | + id: check-bots |
| 25 | + run: | |
| 26 | + # Get all commits in the PR |
| 27 | + git fetch origin ${{ github.event.pull_request.base.ref }} |
| 28 | + COMMITS=$(git log origin/${{ github.event.pull_request.base.ref }}..HEAD --format="%an") |
| 29 | +
|
| 30 | + echo "Commits in PR:" |
| 31 | + echo "$COMMITS" |
| 32 | +
|
| 33 | + # Check if any commits are NOT from bots |
| 34 | + # grep -v returns 0 (true) if it finds lines NOT matching the pattern |
| 35 | + # grep -v returns 1 (false) if all lines match the pattern (all are bots) |
| 36 | + if echo "$COMMITS" | grep -qv '\[bot\]'; then |
| 37 | + echo "Found human commits" |
| 38 | + echo "has_human_commits=true" >> $GITHUB_OUTPUT |
| 39 | + else |
| 40 | + echo "All commits are from bots" |
| 41 | + echo "has_human_commits=false" >> $GITHUB_OUTPUT |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Check signed commits in PR |
| 45 | + if: steps.check-bots.outputs.has_human_commits == 'true' |
| 46 | + continue-on-error: true |
| 47 | + uses: 1Password/check-signed-commits-action@ed2885f3ed2577a4f5d3c3fe895432a557d23d52 # v1.2.0 |
| 48 | + with: |
| 49 | + comment: | |
| 50 | + ## ⚠️ Unsigned Commits Detected |
| 51 | +
|
| 52 | + This pull request contains unsigned commits. |
| 53 | +
|
| 54 | + ### What does this mean? |
| 55 | +
|
| 56 | + Signed commits help ensure the authenticity and traceability of contributions. They allow us to verify that commits actually came from the stated author, even if GitHub accounts are deleted or modified in the future. |
| 57 | +
|
| 58 | + ### Current Policy (Grace Period) |
| 59 | +
|
| 60 | + **This is currently a warning only.** We are in a transition period to give all contributors time to set up commit signing. |
| 61 | +
|
| 62 | + After this grace period, **all commits will be required to be signed** before PRs can be merged. |
| 63 | +
|
| 64 | + ### How to sign your commits |
| 65 | +
|
| 66 | + Please see our [Contributing Guide](../blob/main/CONTRIBUTING.md#setting-up-your-development-environment) for detailed instructions on setting up commit signing. |
| 67 | +
|
| 68 | + ### Resources |
| 69 | +
|
| 70 | + - [Contributing Guide: Development Setup](../blob/main/CONTRIBUTING.md#setting-up-your-development-environment) |
| 71 | + - [GitHub Docs: About Commit Signature Verification](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) |
| 72 | +
|
| 73 | + --- |
| 74 | +
|
| 75 | + _This check will become mandatory in the future. Please start signing your commits now to avoid issues later._ |
0 commit comments