From 5284159e64c18166280986b69ea1013d6b4a0d64 Mon Sep 17 00:00:00 2001 From: Yann Michel Date: Fri, 19 Sep 2025 12:05:29 +0000 Subject: [PATCH] =?UTF-8?q?Mettre=20=C3=A0=20jour=20le=20fichier=20.gitlab?= =?UTF-8?q?-ci.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..ce2a8b3 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,40 @@ +# GitLab CI for RH + +stages: + - deploy + +deploy-job: + stage: deploy + rules: + - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"' + when: always + environment: production + before_script: + ## Install ssh-agent if not already installed, it is required by Docker. + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' + + ## Run ssh-agent (inside the build environment) + - eval $(ssh-agent -s) + + ## Give the right permissions, otherwise ssh-add will refuse to add files + ## Add the SSH key stored in SSH_PRIVATE_KEY file type CI/CD variable to the agent store + - chmod 400 "$SSH_PRIVATE_KEY" + - ssh-add "$SSH_PRIVATE_KEY" + + ## Create the SSH directory and give it the right permissions + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + + ## Put the scm to known hosts + - ssh-keyscan -t rsa gitea.ctisante.com >> ~/.ssh/known_hosts + + ## Set the git user name and email + - git config --global user.email "bender@ctisante.com" + - git config --global user.name "bender" + - git remote add gitea git@gitea.ctisante.com:cti/rh-gitlab.git + script: + - echo "Pushing to Public Repo..." + - git update-ref -d refs/heads/deploy #delete branch deploy + - git branch deploy + - git push -f gitea deploy:master + - echo "RH module pushed." \ No newline at end of file