I have three stages of branches: local branch → staging → production.
Right now, developers move their code to the staging branch, but I have three pipelines running in staging. I want to run only one pipeline on the master branch. How can I do that?
This is my current .yml file in GitLab:
stages:
- deploy-staging
- deploy-production
deploy-staging:
stage: deploy-staging
tags:
- CD
script:
- echo "Staging deployment started."
- echo updating gittestproject
- ssh [email protected] 'cd /var/www/html/gittestproject; git pull origin staging'
- echo "Deployment Succeed."
rules:
- if: '$CI_COMMIT_BRANCH == "staging"' # Run only if on staging branch
when: manual
deploy-production:
stage: deploy-production
tags:
- CD
script:
- echo "Production deployment started."
- echo updating gittestproject
- ssh [email protected] 'cd /var/www/html/gittestproject_production; git pull origin master'
- echo "Deployment Succeed."
rules:
- if: '$CI_COMMIT_BRANCH == "master"' # Run only if on master branch
when: manual