Skip to content

Commit bf1a77e

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

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

Lines changed: 17 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,27 @@ 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
11+
- name: Count commits in PR
1712
id: commits
1813
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
14+
PR_NUMBER=${{ github.event.pull_request.number }}
15+
REPO_OWNER=${{ github.repository_owner }}
16+
REPO_NAME=${{ github.event.repository.name }}
17+
18+
COMMIT_COUNT=$(curl -s \
19+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
20+
-H "Accept: application/vnd.github+json" \
21+
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/commits" \
22+
| jq '. | length')
23+
24+
echo "commit_count=$COMMIT_COUNT" >> $GITHUB_OUTPUT
2225
2326
- name: Enforce single commit
2427
run: |
25-
if [ "${{ steps.commits.outputs.count }}" -gt 1 ]; then
26-
echo "❌ PR has more than one commit (${{ steps.commits.outputs.count }} commits)."
28+
if [ "${{ steps.commits.outputs.commit_count }}" -gt 1 ]; then
29+
echo "❌ PR has more than one commit (${{
30+
steps.commits.outputs.commit_count }})"
2731
exit 1
2832
else
29-
echo "✅ PR has 1 commit."
33+
echo "✅ PR has a single commit"
3034
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)