From a1272b6cdbf54d3d51f944c7d9570810bc58f810 Mon Sep 17 00:00:00 2001
From: Dantali0n <info@dantalion.nl>
Date: Mon, 2 Oct 2023 13:16:17 +0200
Subject: [PATCH] Prevent duplicate job submissions and detached pipelines

---
 docker/ci-runner/Dockerfile                  | 2 +-
 {{cookiecutter.project_slug}}/.gitlab-ci.yml | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/docker/ci-runner/Dockerfile b/docker/ci-runner/Dockerfile
index 29852da..3a31e04 100644
--- a/docker/ci-runner/Dockerfile
+++ b/docker/ci-runner/Dockerfile
@@ -24,7 +24,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
 		python3-breathe \
         python3-pip \
 	&& \
-	rm -rf /var/lib/apt/lists/* \
+	rm -rf /var/lib/apt/lists/*
 
 RUN python3 -m pip install --upgrade pip
 RUN pip install --upgrade cookiecutter tox twine
\ No newline at end of file
diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml
index 9939665..1ef8720 100644
--- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml
+++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml
@@ -4,6 +4,13 @@
 default:
   image: $CI_REGISTRY_IMAGE/ci-build-runner:$CI_COMMIT_REF_SLUG
 
+workflow:
+  rules:
+    # Do not create (detached) pipelines on merge request events
+    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+      when: never
+    - when: always
+
 stages:
   - prepare
   - linting
-- 
GitLab