From 59e2b2ec03beb2dfe43765ede656954df044a831 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20St=C3=BChmer?= <me@samtrion.net>
Date: Thu, 23 May 2024 14:59:42 +0200
Subject: [PATCH] feat: Added `wagoid/commitlint-github-action` as a build step
 (#59)

---
 .github/workflows/ci-dotnet-fast.yml       |  7 +++++
 .github/workflows/cicd-dotnet.yml          | 11 ++++++++
 .github/workflows/step-node-commitlint.yml | 33 ++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 .github/workflows/step-node-commitlint.yml

diff --git a/.github/workflows/ci-dotnet-fast.yml b/.github/workflows/ci-dotnet-fast.yml
index e1307d1..cb0db53 100644
--- a/.github/workflows/ci-dotnet-fast.yml
+++ b/.github/workflows/ci-dotnet-fast.yml
@@ -31,8 +31,15 @@ env:
   NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
 
 jobs:
+  commitlinter:
+    name: Lint commit messages
+    uses: ./.github/workflows/step-commitlint.yml
+    secrets: inherit
+
   build-and-test:
     name: Build and Test ${{ inputs.solution }}
+    needs:
+      - commitlinter
     runs-on: ubuntu-latest
     steps:
       - name: Checkout repository
diff --git a/.github/workflows/cicd-dotnet.yml b/.github/workflows/cicd-dotnet.yml
index c29cb07..b261840 100644
--- a/.github/workflows/cicd-dotnet.yml
+++ b/.github/workflows/cicd-dotnet.yml
@@ -62,8 +62,15 @@ env:
   DOTNET_NOLOGO: true
 
 jobs:
+  commitlinter:
+    name: Lint commit messages
+    uses: ./.github/workflows/step-commitlint.yml
+    secrets: inherit
+
   version:
     name: Version
+    needs:
+      - commitlinter
     uses: ./.github/workflows/step-dotnet-version.yml
     with:
       dotnet-version: ${{ inputs.dotnet-version || '8.x' }}
@@ -72,6 +79,8 @@ jobs:
 
   format:
     name: Format
+    needs:
+      - commitlinter
     if: ${{ inputs.disableCodeFormat == false }}
     uses: ./.github/workflows/step-dotnet-format.yml
     with:
@@ -84,6 +93,8 @@ jobs:
 
   codeql:
     name: CodeQL
+    needs:
+      - commitlinter
     if: ${{ inputs.disableCodeQL == false }}
     uses: ./.github/workflows/step-dotnet-codeql.yml
     with:
diff --git a/.github/workflows/step-node-commitlint.yml b/.github/workflows/step-node-commitlint.yml
new file mode 100644
index 0000000..64e1ff5
--- /dev/null
+++ b/.github/workflows/step-node-commitlint.yml
@@ -0,0 +1,33 @@
+on:
+  workflow_call:
+    secrets:
+      FETCH_TOKEN:
+        required: false
+
+permissions:
+  contents: read
+  pull-requests: read
+
+jobs:
+  commitlint:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+          submodules: recursive
+          token: ${{ secrets.FETCH_TOKEN || github.token }}
+
+      - uses: actions/setup-node@v2
+        with:
+          node-version: '14'
+
+      - name: Install dependencies
+        run: npm install
+
+      # Run the commitlint action, considering its own dependencies and yours as well 🚀
+      # `github.workspace` is the path to your repository.
+      - uses: wagoid/commitlint-github-action@v6
+        env:
+          NODE_PATH: ${{ github.workspace }}/node_modules
\ No newline at end of file