Skip to content

Instantly share code, notes, and snippets.

@riyas-rawther
Created December 7, 2021 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riyas-rawther/e2c4d303a8c43066bcd37cdea4db95c4 to your computer and use it in GitHub Desktop.
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.
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