← back to Exo
chore: Fail pipeline if working tree changes instead of committing them in CI
596b069f84b035b4112a683ffe24506be98300d4 · 2025-06-30 09:40:47 +0100 · Alex Cheema
Files touched
A .github/actions/verify-clean/action.ymlM .github/workflows/pipeline.yml
Diff
commit 596b069f84b035b4112a683ffe24506be98300d4
Author: Alex Cheema <alexcheema123@gmail.com>
Date: Mon Jun 30 09:40:47 2025 +0100
chore: Fail pipeline if working tree changes instead of committing them in CI
---
.github/actions/verify-clean/action.yml | 20 ++++++++++++++++++++
.github/workflows/pipeline.yml | 21 +++++++--------------
2 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/.github/actions/verify-clean/action.yml b/.github/actions/verify-clean/action.yml
new file mode 100644
index 00000000..976e6a7d
--- /dev/null
+++ b/.github/actions/verify-clean/action.yml
@@ -0,0 +1,20 @@
+name: Verify Clean Working Tree
+
+description: "Fail the job if the previous step left the working tree dirty"
+
+inputs:
+ step:
+ description: "The name of the step that just executed"
+ required: true
+
+runs:
+ using: composite
+ steps:
+ - name: Check git diff
+ shell: bash
+ run: |
+ if ! git diff --quiet; then
+ echo "Error: ${{ inputs.step }} left working tree dirty." >&2
+ git --no-pager diff >&2
+ exit 1
+ fi
\ No newline at end of file
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml
index 1de76b8b..7b30d287 100644
--- a/.github/workflows/pipeline.yml
+++ b/.github/workflows/pipeline.yml
@@ -31,7 +31,7 @@ jobs:
needs: typecheck
runs-on: ubuntu-22.04
permissions:
- contents: write
+ contents: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
@@ -52,25 +52,18 @@ jobs:
- uses: ./.github/actions/regenerate-protobufs
- - name: Commit regenerated protobufs
- uses: ./.github/actions/conditional-commit
+ - uses: ./.github/actions/verify-clean
with:
- message: "chore(proto) regenerate protobufs"
+ step: regenerate-protobufs
- uses: ./.github/actions/format
- - name: Commit formatted code
- uses: ./.github/actions/conditional-commit
+ - uses: ./.github/actions/verify-clean
with:
- message: "chore(format): format code"
+ step: format
- uses: ./.github/actions/lint
- - name: Commit lint fixes
- uses: ./.github/actions/conditional-commit
+ - uses: ./.github/actions/verify-clean
with:
- message: "chore(lint): fix linting errors"
-
- - name: Push changes
- run: git push
- shell: bash
+ step: lint
← c0b8bb9c chore: Rename conditional-commit.yml to action.yml
·
back to Exo
·
refactor: Put type defs on one line aae3e4a8 →