From dd99ceb0ce024a92d6d266678d11039d162c9af0 Mon Sep 17 00:00:00 2001
From: "sebastien.heurtematte" <sebastien.heurtematte@eclipse-foundation.org>
Date: Tue, 8 Nov 2022 10:04:32 +0100
Subject: [PATCH] ci: change PAT to oniro core bot token

Related to https://gitlab.eclipse.org/eclipse-wg/oniro-wg/products-services-oniro-wg/it-services-oniro-wg/pipelines-architecture-oniro-wg/-/issues/38

Signed-off-by: sebastien.heurtematte <sebastien.heurtematte@eclipse-foundation.org>
---
 .gitlab-ci.yml | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 43d6d9a..175dce1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -104,6 +104,8 @@ reuse:
     # that modify oniro.git in any way (e.g. a branch, a pull request or merge
     # train).
     GIT_STRATEGY: none
+    CI_GITLAB_USER_ID: "oniro-core-bot"
+    CI_GITLAB_USER_EMAIL: "oniro-core-bot@eclipse.org"
   cache:
     - key:
         prefix: repo-mirror-$CI_ONIRO_MANIFEST_MIRROR_REPO_REV
@@ -143,8 +145,8 @@ reuse:
     # create and send commits.
     - gl_section_open_collapsed setup_git "Setting up git"
     - git config --global --add safe.directory "$CI_PROJECT_DIR"
-    - git config --global user.name "Oniro Core Project Bot"
-    - git config --global user.email "oniro-core-bot@eclipse.org"
+    - git config --global user.email "$CI_GITLAB_USER_EMAIL"
+    - git config --global user.name "$CI_GITLAB_USER_ID"
     - gl_section_close setup_git
 
     # Since CI_PROJECT_DIR is set to 'none', GitLab runner does not perform any
@@ -243,12 +245,17 @@ deploy:
   image:
     name: docker.io/onirocore/docs-builder:latest
   stage: deploy
+  variables:
+    CI_DOC_DEPLOY_REPO: "gitlab.eclipse.org/eclipse/oniro-core/oniro-readthedocs-aggregated.git"
+    CI_DOC_DEPLOY_REPO_BRANCH: "main"
+    CI_GITLAB_USERNAME: "oniro-core-bot"
+    CI_GITLAB_TOKEN: "<api token from gitlab"
   script:
     # We are in the root of the git-repo workspace. Because
     # .oniro-repo-workspace uses GIT_STRATEGY=none, the workspace is not
     # cleaned automatically.
     - rm -rf aggregated
-    - git clone https://user:$CI_ONIRO_AGGREGATED_DOCS_TOKEN@gitlab.eclipse.org/eclipse/oniro-core/oniro-readthedocs-aggregated.git aggregated
+    - git clone https://$CI_GITLAB_USERNAME:$CI_GITLAB_TOKEN@$CI_DOC_DEPLOY_REPO aggregated
     - find aggregated -maxdepth 1 -not -path aggregated/.git -not -path aggregated -exec rm -rvf {} \;
     - tar -c --dereference -C docs --exclude ./.git --exclude ./.gitlab-ci.yml . | tar -x -C aggregated
     # Commit and push back, if something changed.
@@ -258,7 +265,7 @@ deploy:
         msg="docs repository snapshot - $CI_COMMIT_BRANCH:$CI_COMMIT_SHA";
         git add -A;
         git commit -sm "$msg";
-        git push origin HEAD:main;
+        git push origin HEAD:$CI_DOC_DEPLOY_REPO_BRANCH;
       else
         echo "Nothing new to commit.";
       fi
-- 
GitLab