Created
December 7, 2021 08:19
-
-
Save riyas-rawther/e2c4d303a8c43066bcd37cdea4db95c4 to your computer and use it in GitHub Desktop.
gitlab-ci.yml file for running a pipeline only on a specific branch, using specific runners and when releasing (tag) manually.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deploy_development: | |
stage: deploy | |
only: | |
- development # Limit this job to the staging branch | |
script: | |
- echo "Deploy to staging server" | |
- cd /var/www/stagingadmin.example.com | |
- sudo git stash | |
- sudo git fetch | |
- sudo git pull | |
- sudo npm i | |
- sudo ng build --configuration staging | |
- sudo systemctl reload nginx | |
- sudo chown -R nginx:nginx /var/www/stagingadmin.example.com/dist | |
tags: | |
- staging # use the runner called staging | |
environment: | |
name: staging | |
url: https://staging-api.example.com/ | |
#NOTE:# | |
#the above script only run if there is a release tag on the development branch. And it will run using a runner named "staging". It will run using the gitlab-ci.yml included on the development branch. So any commands above will not work. | |
deploy_uat: | |
stage: deploy | |
only: | |
- uat # Limit this job to the uat branch | |
script: | |
- echo "Deploy to UAT server" | |
- cd /var/www/uatadmin.example.com | |
- sudo git stash | |
- sudo git fetch | |
- sudo git pull | |
- sudo npm i | |
- sudo ng build --configuration uat | |
- sudo systemctl reload nginx | |
- sudo chown -R nginx:nginx /var/www/uatadmin.example.com/dist | |
tags: | |
- uat-runner # use the runner called uat-runner | |
# - staging | |
# On a single server, if deploying multiple branches on diffrent folders, then single runner is only required! | |
# above, we can either use uat-runner or runner named staging. | |
only: | |
- tags # only run when creating a new release | |
environment: | |
name: uatadmin | |
url: https://uatadmin.example.com/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment