From 38b082d98722f0fa01077543a0d0eda7f8f913c5 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Fri, 8 Apr 2022 22:03:12 +0300
Subject: [PATCH] Rules for pre-commit templates.

Only run when the relevanet files exist.
---
 templates/pre-commit-repo.yml | 3 +++
 templates/pre-commit.yml      | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/templates/pre-commit-repo.yml b/templates/pre-commit-repo.yml
index 40afdec..1e5bb6b 100644
--- a/templates/pre-commit-repo.yml
+++ b/templates/pre-commit-repo.yml
@@ -3,6 +3,9 @@ pre-commit-repo:
   stage: test
   image: registry.shore.co.il/ci-images:pre-commit
   tags: [ns4.shore.co.il]
+  rules:
+    - exists:
+        - .pre-commit-hooks.yaml
   variables:
     XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache"
   script:
diff --git a/templates/pre-commit.yml b/templates/pre-commit.yml
index 5607c5c..447dce4 100644
--- a/templates/pre-commit.yml
+++ b/templates/pre-commit.yml
@@ -6,6 +6,8 @@ pre-commit:
   tags: [ns4.shore.co.il]
   rules:
     - if: $CI_PIPELINE_SOURCE != "schedule"
+      exists:
+        - .pre-commit-config.yaml
   variables:
     XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache"
     SKIP: |-
-- 
GitLab