.gitlab-ci.yml 2.74 KB
Newer Older
1 2 3
include:
  - template: SAST.gitlab-ci.yml
  - template: Secret-Detection.gitlab-ci.yml
4
  - template: Verify/Accessibility.gitlab-ci.yml
5
  - project: eggerd/ci
Dustin Eckhardt's avatar
Dustin Eckhardt committed
6 7 8 9 10
    file: 
      - deploy.gitlab-ci.yml
      - sonarqube.gitlab-ci.yml
      - code-intell.gitlab-ci.yml
      - lighthouse.gitlab-ci.yml
11 12 13

default:
  image: eggerd/gitlab
Dustin Eckhardt's avatar
Dustin Eckhardt committed
14 15 16 17 18 19

stages:
  - build
  - test
  - analyse
  - deploy
20
  - checkup
Dustin Eckhardt's avatar
Dustin Eckhardt committed
21 22

variables:
23
  # List of files and folders that will be ignored during deploy, separated by spaces.
Dustin Eckhardt's avatar
Dustin Eckhardt committed
24 25 26
  # Ignored entries will neither be deployed nor deleted on the remote host, if they exist there.
  # All files and folders whose name start with a dot are always ignored (except .htaccess)
  DEPLOY_IGNORE: ""
Dustin Eckhardt's avatar
Dustin Eckhardt committed
27
  PUBLIC_URL_PROD: "https://pixel-diary.eggerd.de"
Dustin Eckhardt's avatar
Dustin Eckhardt committed
28 29
  PUBLIC_URL_TEST: "https://test.eggerd.de/pixel-diary/"

30
.build:
Dustin Eckhardt's avatar
Dustin Eckhardt committed
31 32
  stage: build
  script:
Dustin Eckhardt's avatar
Dustin Eckhardt committed
33
    - npm install
34 35
    - echo "PUBLIC_URL=$public_url" >> .env
    - echo "REACT_APP_ENVIRONMENT=$environment" >> .env
Dustin Eckhardt's avatar
Dustin Eckhardt committed
36 37 38 39
    - npm run build
  artifacts:
    paths:
      - ./build/
40 41 42 43

build-prod:
  extends: .build
  variables:
44 45
    public_url: $PUBLIC_URL_PROD
    environment: production
46 47
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'
Dustin Eckhardt's avatar
Dustin Eckhardt committed
48

49 50 51
build-test:
  extends: .build
  variables:
52 53
    public_url: $PUBLIC_URL_TEST
    environment: testing
54 55
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop"'
56

Dustin Eckhardt's avatar
Dustin Eckhardt committed
57 58 59 60
unit-tests:
  stage: test
  dependencies: []
  script:
Dustin Eckhardt's avatar
Dustin Eckhardt committed
61
    - npm install
Dustin Eckhardt's avatar
Dustin Eckhardt committed
62
    - npm test -- --coverage
63 64 65
  rules:
    - if: '$CI_COMMIT_BRANCH'
      allow_failure: true
Dustin Eckhardt's avatar
Dustin Eckhardt committed
66

67 68 69 70 71 72
secret_detection_default_branch:
  stage: analyse

secret_detection:
  stage: analyse

Dustin Eckhardt's avatar
Dustin Eckhardt committed
73 74
sast:
  stage: analyse
75
  dependencies: []
Dustin Eckhardt's avatar
Dustin Eckhardt committed
76

77 78 79 80 81 82
lint:
  stage: analyse
  dependencies: []
  script:
    - npm install
    - npm run lint
83 84 85
  rules:
    - if: '$CI_COMMIT_BRANCH'
      allow_failure: true
86

Dustin Eckhardt's avatar
Dustin Eckhardt committed
87
sonarqube:
88 89 90 91 92
  extends: .sonarqube
  variables:
    project_name: "Pixel Diary"
    project_key: "pixel-diary"
    login_token: $SONARQUBE_LOGIN_TOKEN  
Dustin Eckhardt's avatar
Dustin Eckhardt committed
93 94

deploy-test:
95 96 97 98 99 100 101 102
  extends: .deploy
  dependencies: [ build-test ]
  variables:
    deploy_ignore: $DEPLOY_IGNORE
    ssh_username: $SSH_TEST_USERNAME
    ssh_port: $SSH_TEST_PORT
    ssh_key: $SSH_TEST_KEY
  environment: Staging
103 104
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop"'
105 106 107

pages:
  stage: deploy
108
  dependencies: [ build-prod ]
109
  script:
Dustin Eckhardt's avatar
Dustin Eckhardt committed
110
    - rm -rf ./public
111 112
    - mv ./build ./public
  artifacts:
113 114
    paths: [ ./public ]
  environment: Production
115 116 117
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'
      when: manual
118 119 120 121 122 123 124 125 126 127 128 129 130

a11y:
  stage: checkup
  variables:
    a11y_urls: https://staging.eggerd.de/pixel-diary/
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE != "schedule"'

lighthouse:
  variables:
    url: https://staging.eggerd.de/pixel-diary/
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE != "schedule"'