# GitLab CI for PMSI 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" script: - echo "Initializing Git..." - git remote add gitea git@gitea.ctisante.com:cti/pmsi-gitlab.git - echo "Pushing to Public Repo..." - git push -f gitea master - echo "Application pushed."