From 31f38b133377ec11f65f1109998d9a09f35def80 Mon Sep 17 00:00:00 2001 From: Ronan Hennessy Date: Fri, 24 Oct 2025 12:30:23 +0100 Subject: [PATCH 1/2] Testing single-commit action --- .github/workflows/check-single-commit.yml | 34 +++++++++++++++++++++++ test.adoc | 1 + 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/check-single-commit.yml create mode 100644 test.adoc diff --git a/.github/workflows/check-single-commit.yml b/.github/workflows/check-single-commit.yml new file mode 100644 index 000000000000..e3f909f2e566 --- /dev/null +++ b/.github/workflows/check-single-commit.yml @@ -0,0 +1,34 @@ +name: Check single commit + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + check-single-commit: + runs-on: ubuntu-latest + steps: + - name: Count commits in PR + id: commits + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + REPO_OWNER=${{ github.repository_owner }} + REPO_NAME=${{ github.event.repository.name }} + + COMMIT_COUNT=$(curl -s \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/commits" \ + | jq '. | length') + + echo "commit_count=$COMMIT_COUNT" >> $GITHUB_OUTPUT + + - name: Enforce single commit + run: | + if [ "${{ steps.commits.outputs.commit_count }}" -gt 1 ]; then + echo "❌ PR has more than one commit (${{ + steps.commits.outputs.commit_count }})" + exit 1 + else + echo "✅ PR has a single commit" + fi diff --git a/test.adoc b/test.adoc new file mode 100644 index 000000000000..33735d6ae520 --- /dev/null +++ b/test.adoc @@ -0,0 +1 @@ +This is the second commit and should trigger the single commit check to fail. \ No newline at end of file From adcb300e257f9bc2335bbcc7afe613a4a360abdb Mon Sep 17 00:00:00 2001 From: Ronan Hennessy Date: Fri, 24 Oct 2025 13:45:47 +0100 Subject: [PATCH 2/2] commit 2 --- test.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.adoc b/test.adoc index 33735d6ae520..74214361a79b 100644 --- a/test.adoc +++ b/test.adoc @@ -1 +1 @@ -This is the second commit and should trigger the single commit check to fail. \ No newline at end of file +This is again a second commit and should trigger the single commit check to fail. \ No newline at end of file