Browse Source

Mettre à jour le fichier .gitlab-ci.yml

master
Yann Michel 2 months ago
parent
commit
b50bdd5bd1
1 changed files with 40 additions and 0 deletions
  1. +40
    -0
      .gitlab-ci.yml

+ 40
- 0
.gitlab-ci.yml View File

@ -0,0 +1,40 @@
# GitLab CI for Eco
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/eco-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 "Activite module pushed."

Loading…
Cancel
Save