Fakultas Ilmu Komputer UI

.gitlab-ci.yml 1.54 KB
Newer Older
1
image: node:12.16.3-buster-slim
WILLIAM GATES's avatar
WILLIAM GATES committed
2
stages:
WILLIAM GATES's avatar
WILLIAM GATES committed
3
  - lint
WILLIAM GATES's avatar
WILLIAM GATES committed
4
  - test
WILLIAM GATES's avatar
WILLIAM GATES committed
5
  - sonar_scanner_test
WILLIAM GATES's avatar
WILLIAM GATES committed
6
7
  - deploy

WILLIAM GATES's avatar
WILLIAM GATES committed
8
9
10
11
12
13
lint:
  stage: lint
  script:
    - npm install
    - npm run lint

WILLIAM GATES's avatar
WILLIAM GATES committed
14
15
test:
  stage: test
WILLIAM GATES's avatar
WILLIAM GATES committed
16
17
18
19
20
  artifacts:
    expire_in: 1 hour
    paths:
      - coverage/lcov.info
      - test-report.xml
WILLIAM GATES's avatar
WILLIAM GATES committed
21
22
23
24
  script:
    - npm install
    - npm run test:coverage

WILLIAM GATES's avatar
WILLIAM GATES committed
25
26
27
28
29
30
31
32
33
34
sonar_scanner_test:
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  stage: sonar_scanner_test
  dependencies:
    - test
  script:
    - sonar-scanner -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY -Dsonar.host.url=$SONARQUBE_HOST_URL -Dsonar.login=$SONARQUBE_TOKEN -Dsonar.branch.name=$CI_COMMIT_REF_NAME

WILLIAM GATES's avatar
WILLIAM GATES committed
35
36
37
38
39
staging:
  stage: deploy
  variables:
    NETLIFY_AUTH_TOKEN: $STAGING_NETLIFY_AUTH_TOKEN
    NETLIFY_SITE_ID: $STAGING_NETLIFY_SITE_ID
40
    REACT_APP_BASE_URL: $STAGING_REACT_APP_BASE_URL
WILLIAM GATES's avatar
WILLIAM GATES committed
41
42
  script:
    - npm install
WILLIAM GATES's avatar
WILLIAM GATES committed
43
    - CI=false npm run build
44
    - npm install netlify-cli -g --unsafe-perm
WILLIAM GATES's avatar
WILLIAM GATES committed
45
    - netlify deploy --dir dist --prod
WILLIAM GATES's avatar
WILLIAM GATES committed
46
47
48
49
50
51
52
53
54
  only:
    - staging

production:
  stage: deploy
  variables:
    AWS_ACCESS_KEY_ID: $PRODUCTION_AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $PRODUCTION_AWS_SECRET_ACCESS_KEY
    AWS_STORAGE_BUCKET_NAME: $PRODUCTION_AWS_STORAGE_BUCKET_NAME
55
    REACT_APP_BASE_URL: $PRODUCTION_REACT_APP_BASE_URL
WILLIAM GATES's avatar
WILLIAM GATES committed
56
57
58
59
60
61
62
63
64
65
  script:
    - npm install
    - CI=false npm run build
    - apt update -y && apt install python3-dev python3-pip zip -y
    - pip3 install awscli
    - cd dist
    - zip -r home-industry.zip *
    - aws s3 cp home-industry.zip s3://$AWS_STORAGE_BUCKET_NAME
  only:
    - master