Skip to content

Commit 2a2baa3

Browse files
committed
Testing single-commit action
1 parent cfc69c6 commit 2a2baa3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test Single Commit
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
7+
jobs:
8+
check-single-commit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Count commits
17+
id: commits
18+
run: |
19+
BASE_BRANCH="${{ github.event.pull_request.base.ref }}"
20+
COMMIT_COUNT=$(git rev-list --count --no-merges origin/$BASE_BRANCH..HEAD)
21+
echo "count=$COMMIT_COUNT" >> $GITHUB_OUTPUT
22+
23+
- name: Enforce single commit
24+
run: |
25+
if [ "${{ steps.commits.outputs.count }}" -gt 1 ]; then
26+
echo "❌ PR has more than one commit (${{ steps.commits.outputs.count }} commits)."
27+
exit 1
28+
else
29+
echo "✅ PR has 1 commit."
30+
fi

0 commit comments

Comments
 (0)