2 Runners, One for dev, one for prod, how to differentiate between the two

My Problem

I want to have 2 runners, one for production deployment, one for development deployment. I am in the process of writing my gitlab yaml and setting up the pipeline and process.

Im just looking for guidance on how to do this. I know when setting up the runner that I can define tags to be used by the runner. So I have a tag of production tied to the runner I want to be used for production deployments also with a branch called production. Same goes for development. Im just trying to figure out how to run split. as I only want the production runner to only do production branch pipeline and development to run everything else. Just trying to determine the best approach to have the dev branch deploy to dev servers and then the production branch deploy to production servers

Configuration

This is what I have so far for a config file. Just trying to figure this out.

stages:
  - test        
  - deploy

spell-check-job: 
  stage: test   
  script:
    - aspell -H check index.html

dev_deploy_site:
  stage: deploy
  environment: development
  script:
    - echo Testing
  rules:
    - if: '$CI_COMMIT_BRANCH == "development"'


prod_deploy-site:    
  stage: deploy  
  environment: production
  script:
    - echo "Copying to server"
    - echo "Application successfully deployed."
  rules:
    - if: '$CI_COMMIT_BRANCH == "production"'

Versions

Please select whether options apply, and add the version information.

  • [X ] Self-managed
  • GitLab.com SaaS
  • [X ] Self-hosted Runners

Versions

  • GitLab : v16.9.2-ee
  • No runners currently installed or configured

Thanks for the read. Just looking for guidance on how to accomplish this.

Take a look at CI/CD YAML syntax reference | GitLab. You add tags dev resp. prod to your runners and add the tags element to your .gitlab-ci.yml:

prod_deploy-site:
   tags:
   - prod
....

Awesome Thank you!