Skip to content

Commit db44434

Browse files
committed
Testing second commit
1 parent 2a2baa3 commit db44434

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test Single Commit
1+
name: Check single commit
22

33
on:
44
pull_request:
@@ -8,23 +8,17 @@ jobs:
88
check-single-commit:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Checkout code
12-
uses: actions/checkout@v4
13-
with:
14-
fetch-depth: 0
15-
16-
- name: Count commits
17-
id: commits
11+
- name: Check PR commit count
12+
id: pr
1813
run: |
19-
BASE_BRANCH="${{ github.event.pull_request.base.ref }}"
20-
COMMIT_COUNT=$(git rev-list --count --no-merges origin/$BASE_BRANCH..HEAD)
14+
COMMIT_COUNT=$(gh pr view ${{ github.event.pull_request.number }} --json commits -q '.commits | length')
2115
echo "count=$COMMIT_COUNT" >> $GITHUB_OUTPUT
2216
2317
- name: Enforce single commit
2418
run: |
25-
if [ "${{ steps.commits.outputs.count }}" -gt 1 ]; then
26-
echo "❌ PR has more than one commit (${{ steps.commits.outputs.count }} commits)."
19+
if [ "${{ steps.pr.outputs.count }}" -gt 1 ]; then
20+
echo "❌ PR has more than one commit (${{ steps.pr.outputs.count }})."
2721
exit 1
2822
else
29-
echo "✅ PR has 1 commit."
23+
echo "✅ PR has a single commit."
3024
fi

test.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is the second commit and should trigger the single commit check to fail.

0 commit comments

Comments
 (0)