From 70505a8034d214a9fcc2697ac7e33401f17cc38c Mon Sep 17 00:00:00 2001
From: Emanuele Aina <emanuele.aina@collabora.com>
Date: Wed, 28 Oct 2020 12:32:07 +0100
Subject: [PATCH] gitlab-ci: Fix the pipeline on forks

Our guidelines say that to contribute people should fork repositories,
but at the moment this gives them a broken pipeline.

Tweak things in a way that the main project triggers
tests/apertis-test-cases-web to collect and indirectly publish all the
release branches while forked repositories directly publish their own
branches via Pages for easier testing.

Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
---
 .gitlab-ci.yml | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3edb186b..ae6531e8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,8 +21,24 @@ render-pages:
     paths:
       - ${release}
 
+# the main project triggers tests/apertis-test-cases-web to collect and indirectly publish all the release branches
 deploy-pages:
   stage: deploy
   trigger:
     project: tests/apertis-test-cases-web
     branch: main
+  rules:
+    - if: $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_PATH == "tests/apertis-test-cases"
+
+# forked repositories publish directly to Pages their own branches for easier testing
+pages:
+  stage: deploy
+  script:
+    - mv ${release} public/
+  rules:
+    - if: $CI_PROJECT_PATH == "tests/apertis-test-cases"
+      when: never
+    - if: $CI_PIPELINE_SOURCE == "push"
+  artifacts:
+    paths:
+      - public/
-- 
GitLab