gitlab ci

gitlab ci requires a .gitlab-ci.yml file in the root of your repository.

REACT and gitlab ci

let me show my .gitlab-ci.yml file

deploy test:
  stage: deploy
  tags:
    - dev-102
  script:
    - cd /home/apollo/test/surge-frontend
    - CI='' git pull
    - git checkout $CI_COMMIT_REF_NAME
    - CI='' git pull
    - CI='' npm run build

deploy prod:
  stage: deploy
  tags:
    - dev-102
  script:
    - cd /home/apollo/surge-frontend
    - git checkout master
    - CI='' git pull
    - CI='' npm run build
  only:
    - master

I have deployed a gitlab runner in the server, and tag the runner with dev-102, yml file config tags with dev-102, so the job will run in the server.
let’s see the deploy test script part, I have clone the repository to the path /home/apollo/test/surge-frontend and config the nginx server this path, so next step is git pull and git checkout $CI_COMMIT_REF_NAME, then npm run build to build the project.
in the ci progress, if command has warning, the job will fail, so I add CI='' before the command, to ignore the warning.

depploy prod have a only config, it will run when we merge branch to master.