You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
1.3 KiB

# 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"
- git remote add gitea git@gitea.ctisante.com:cti/compta-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 "Compta module pushed."