From 34c468374df544a82e328e4e06f5711ebf4d9f49 Mon Sep 17 00:00:00 2001
From: Laurent BEAULATON <laurent.beaulaton@ofb.gouv.fr>
Date: Mon, 7 Oct 2024 10:01:59 +0200
Subject: [PATCH 1/5] pkgdown prod

---
 gitlab-ci/pkgdown.gitlab-ci.yml     |  2 +-
 gitlab-ci/publication.gitlab-ci.yml | 45 +++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 gitlab-ci/publication.gitlab-ci.yml

diff --git a/gitlab-ci/pkgdown.gitlab-ci.yml b/gitlab-ci/pkgdown.gitlab-ci.yml
index eb6133d..c9c252d 100644
--- a/gitlab-ci/pkgdown.gitlab-ci.yml
+++ b/gitlab-ci/pkgdown.gitlab-ci.yml
@@ -7,7 +7,7 @@
       - Rscript -e 'pak::pkg_install(pkg = c("pkgdown"), upgrade = FALSE)'
       - Rscript -e 'pak::pak(pkg = ".", upgrade = FALSE)'
       - Rscript -e 'pkgdown::build_site()'
-      - cp -r docs/* public/documentation
+      - cp -r docs/* public
     artifacts:
       paths:
         - public
diff --git a/gitlab-ci/publication.gitlab-ci.yml b/gitlab-ci/publication.gitlab-ci.yml
new file mode 100644
index 0000000..f2d5f7d
--- /dev/null
+++ b/gitlab-ci/publication.gitlab-ci.yml
@@ -0,0 +1,45 @@
+.publication:
+    stage: deploy
+    allow_failure: true
+    when: on_success
+    script:
+      - echo "publication"
+    artifacts:
+      paths:
+        - public
+      expire_in: 30 days
+
+# en dev
+publication-dev:
+  extends:
+    - .rules_other
+    - .publication
+    - .image-dev
+  needs: ["pkgdown-dev"]
+  environment:
+    name: $CI_COMMIT_REF_SLUG
+    url: https://$CI_PROJECT_NAMESPACE.$CI_PAGES_DOMAIN/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html
+    on_stop: stop-pkgdown-dev
+
+stop-pkgdown-dev:
+  stage: deploy
+  except:
+      - main
+  script:
+    - echo "Supprime l'environnement de test"
+  environment:
+    name:  $CI_COMMIT_REF_SLUG
+    action: stop
+  when: manual
+
+# en prod
+pages:
+  stage: deploy
+  script:
+      - echo "deployment"
+  artifacts:
+      paths:
+          - public
+  only:
+      - main
+  needs: ["pkgdown-prod"]
\ No newline at end of file
-- 
GitLab


From f5380b616b61e8ffc347d97a544967d1185a8caf Mon Sep 17 00:00:00 2001
From: Laurent BEAULATON <laurent.beaulaton@ofb.gouv.fr>
Date: Mon, 7 Oct 2024 10:06:05 +0200
Subject: [PATCH 2/5] avec publication

---
 .gitlab-ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 10770d6..fddc64a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -54,6 +54,7 @@ include:
   - local: '/gitlab-ci/codecov.gitlab-ci.yml'
   - local: '/gitlab-ci/integration.gitlab-ci.yml'
   - local: '/gitlab-ci/pkgdown.gitlab-ci.yml'
+  - local: '/gitlab-ci/publication.gitlab-ci.yml'
 
 # pour lancer celui là il faudrait avoir un accès à un runner.... pour l'instant j'ai pas....
 #https://guillaumebriday.fr/installer-et-utiliser-les-gitlab-runners
-- 
GitLab


From 6c645adb355697bf02c5c6c492cff9d2efa04bf5 Mon Sep 17 00:00:00 2001
From: Laurent BEAULATON <laurent.beaulaton@ofb.gouv.fr>
Date: Mon, 7 Oct 2024 10:28:58 +0200
Subject: [PATCH 3/5] passage prod aussi

---
 gitlab-ci/rules.gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gitlab-ci/rules.gitlab-ci.yml b/gitlab-ci/rules.gitlab-ci.yml
index fe008cc..c8ef416 100644
--- a/gitlab-ci/rules.gitlab-ci.yml
+++ b/gitlab-ci/rules.gitlab-ci.yml
@@ -10,7 +10,7 @@
 # for main banch only
 .rules_main:
   rules:
-    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_PROTECTED  == "true"	# only if there is changes in the main branch
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_PROTECTED  == "true" || $CI_COMMIT_BRANCH == "59-pkgdown"	# only if there is changes in the main branch
 
 #######################            
 # for shutting down the job
-- 
GitLab


From 365c859bc445865b77d0c8beb766944a7ad6d69c Mon Sep 17 00:00:00 2001
From: Laurent BEAULATON <laurent.beaulaton@ofb.gouv.fr>
Date: Mon, 7 Oct 2024 10:42:54 +0200
Subject: [PATCH 4/5] fix

---
 gitlab-ci/publication.gitlab-ci.yml | 4 ++--
 gitlab-ci/rules.gitlab-ci.yml       | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gitlab-ci/publication.gitlab-ci.yml b/gitlab-ci/publication.gitlab-ci.yml
index f2d5f7d..425359d 100644
--- a/gitlab-ci/publication.gitlab-ci.yml
+++ b/gitlab-ci/publication.gitlab-ci.yml
@@ -34,12 +34,12 @@ stop-pkgdown-dev:
 
 # en prod
 pages:
+  extends:
+    - .rules_main
   stage: deploy
   script:
       - echo "deployment"
   artifacts:
       paths:
           - public
-  only:
-      - main
   needs: ["pkgdown-prod"]
\ No newline at end of file
diff --git a/gitlab-ci/rules.gitlab-ci.yml b/gitlab-ci/rules.gitlab-ci.yml
index c8ef416..81b0d39 100644
--- a/gitlab-ci/rules.gitlab-ci.yml
+++ b/gitlab-ci/rules.gitlab-ci.yml
@@ -4,7 +4,7 @@
 # for any branch, but main
 .rules_other:
   rules:
-    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH != "main" && $CI_COMMIT_REF_PROTECTED  != "true"				# only if there is changes in branch other than main
+    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH != "main" && $CI_COMMIT_REF_PROTECTED  != "true"	&& $CI_COMMIT_BRANCH != "59-pkgdown"			# only if there is changes in branch other than main
 
 #######################            
 # for main banch only
-- 
GitLab


From b1d32b8dcd6dcaf874fc964d8231a28416a33840 Mon Sep 17 00:00:00 2001
From: Laurent BEAULATON <laurent.beaulaton@ofb.gouv.fr>
Date: Mon, 7 Oct 2024 10:53:09 +0200
Subject: [PATCH 5/5] =?UTF-8?q?retour=20=C3=A0la=20nromale?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 gitlab-ci/publication.gitlab-ci.yml | 4 ++--
 gitlab-ci/rules.gitlab-ci.yml       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gitlab-ci/publication.gitlab-ci.yml b/gitlab-ci/publication.gitlab-ci.yml
index 425359d..14621dc 100644
--- a/gitlab-ci/publication.gitlab-ci.yml
+++ b/gitlab-ci/publication.gitlab-ci.yml
@@ -23,8 +23,8 @@ publication-dev:
 
 stop-pkgdown-dev:
   stage: deploy
-  except:
-      - main
+  extends:
+    - .rules_other
   script:
     - echo "Supprime l'environnement de test"
   environment:
diff --git a/gitlab-ci/rules.gitlab-ci.yml b/gitlab-ci/rules.gitlab-ci.yml
index 81b0d39..1294670 100644
--- a/gitlab-ci/rules.gitlab-ci.yml
+++ b/gitlab-ci/rules.gitlab-ci.yml
@@ -4,13 +4,13 @@
 # for any branch, but main
 .rules_other:
   rules:
-    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH != "main" && $CI_COMMIT_REF_PROTECTED  != "true"	&& $CI_COMMIT_BRANCH != "59-pkgdown"			# only if there is changes in branch other than main
+    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH != "main" && $CI_COMMIT_REF_PROTECTED  != "true"	# only if there is changes in branch other than main
 
 #######################            
 # for main banch only
 .rules_main:
   rules:
-    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_PROTECTED  == "true" || $CI_COMMIT_BRANCH == "59-pkgdown"	# only if there is changes in the main branch
+    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_PROTECTED  == "true" # only if there is changes in the main branch
 
 #######################            
 # for shutting down the job
-- 
GitLab