From e39ea73095e807e44ffce274e509e3a5ace204d8 Mon Sep 17 00:00:00 2001
From: Oleg Lobanov <oleg@lobanov.me>
Date: Wed, 24 Apr 2024 22:51:37 +0200
Subject: [PATCH] ci: add pr lint workflow (#3157)

---
 .github/workflows/main.yaml    | 12 +-----------
 .github/workflows/pr-lint.yaml | 21 +++++++++++++++++++++
 Makefile                       |  2 +-
 3 files changed, 23 insertions(+), 12 deletions(-)
 create mode 100644 .github/workflows/pr-lint.yaml

diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
index bc1ce06b..1298b1ff 100644
--- a/.github/workflows/main.yaml
+++ b/.github/workflows/main.yaml
@@ -26,19 +26,9 @@ jobs:
         with:
           go-version: 1.22.1
       - run: make lint-backend
-  lint-commits:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v4
-        with:
-          fetch-depth: 0
-      - uses: actions/setup-node@v4
-        with:
-          node-version: '18'
-      - run: make lint-commits
   lint:
     runs-on: ubuntu-latest
-    needs: [lint-frontend, lint-backend, lint-commits]
+    needs: [lint-frontend, lint-backend]
     steps:
       - run: echo "done"
 
diff --git a/.github/workflows/pr-lint.yaml b/.github/workflows/pr-lint.yaml
new file mode 100644
index 00000000..34ecbb09
--- /dev/null
+++ b/.github/workflows/pr-lint.yaml
@@ -0,0 +1,21 @@
+name: "Lint PR"
+
+on:
+  pull_request_target:
+    types:
+      - opened
+      - reopened
+      - edited
+      - synchronize
+
+permissions:
+  pull-requests: read
+
+jobs:
+  main:
+    name: Validate PR title
+    runs-on: ubuntu-latest
+    steps:
+      - uses: amannn/action-semantic-pull-request@v5
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 743dafe8..baecd0f3 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ test-backend: ## Run backend tests
 	$Q $(go) test -v ./...
 
 .PHONY: lint
-lint: lint-frontend lint-backend lint-commits ## Run all linters
+lint: lint-frontend lint-backend ## Run all linters
 
 .PHONY: lint-frontend
 lint-frontend: ## Run frontend linters