Fakultas Ilmu Komputer UI

.gitlab-ci.yml 3.09 KB
Newer Older
1
2
3
4
5
6
7
8
---
image: python:2-jessie

stages:
  - build
  - test
  - deploy

Zamil Majdy's avatar
Zamil Majdy committed
9
test:
10
11
12
13
14
15
16
  services:
    - postgres:9.6-alpine
  variables:
    POSTGRES_DB: kape
    POSTGRES_USER: kape
    POSTGRES_PASSWORD: kape
  stage: test
Zamil Majdy's avatar
Zamil Majdy committed
17
  script:
18
19
20
21
22
23
24
25
26
27
28
29
    - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
    - sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
    - apt-get update && apt-get install -y google-chrome-stable libappindicator1 libindicator7 libpq-dev libxss1 python-dev python-pip sudo
    - export CHROME_BIN=/usr/bin/google-chrome
    - curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
    - apt-get install -y build-essential nodejs
    - npm install
    - npm run build-production
    - pip install -r requirements.txt
    - python manage.py migrate
    - python manage.py test
    - npm run karma
30
31
32
  artifacts:
    paths:
      - test/
Zamil Majdy's avatar
Zamil Majdy committed
33

34
35
36
37
38
39
40
41
42
43
SonarScanner Analysis:
  image: addianto/sonar-scanner-cli:latest
  stage: test
  script:
    - sonar-scanner
      -Dsonar.host.url=$SONARQUBE_HOST
      -Dsonar.login=$SONARQUBE_TOKEN
  only:
    - master

44
45
46
47
48
49
50
51
52
53
54
pages:
  stage: deploy
  dependencies:
    - test
  script:
    - mv test/ public/
  artifacts:
    paths:
      - public
    expire_in: 30 days
      
Zamil Majdy's avatar
Zamil Majdy committed
55
56
57
staging:
  type: deploy
  script:
58
59
60
61
62
63
64
65
66
67
    - apt-get update -qy
    - apt-get install sshpass
    - git clone https://gitlab.com/PPL2017csui/PPLA1.git
    - cd PPLA1
    - git checkout develop
    - git pull
    - git remote add deployment ssh://kape@bot.recruit.id:8023/home/kape.git
    - mkdir ~/.ssh
    - echo -e "Host bot.recruit.id\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
    - sshpass -p yukcarikape git push deployment develop:master --force
68
  only:
69
    - develop
Zamil Majdy's avatar
Zamil Majdy committed
70
71
72
73

production:
  type: deploy
  script:
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
    - apt-get update -qy
    - apt-get install sshpass
    - git clone https://gitlab.com/PPL2017csui/PPLA1.git
    - cd PPLA1
    - git checkout master
    - git pull
    - git remote add deployment ssh://kape@bot.recruit.id:8022/home/kape.git
    - mkdir ~/.ssh
    - echo -e "Host bot.recruit.id\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
    - sshpass -p yukcarikape git push deployment master:master --force
  when: manual
  only:
    - master

Publish Container Image:
  image: docker:19-git
  stage: deploy
  services:
    # Workaround from https://forum.gitlab.com/t/docker-dind-stops-working-after-12-1-0-update/28664/2
    - name: docker:19-dind
      entrypoint: ["env", "-u", "DOCKER_HOST"]
      command: ["dockerd-entrypoint.sh"]
  variables:
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ""
  before_script:
    - docker info
    - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
  script:
    - docker build
      --build-arg=NPM_PROXY=$NPM_PROXY
      --build-arg=IMAGE_CREATED="$(date --utc -Iseconds)"
      --build-arg=IMAGE_REVISION="$(git show --pretty=oneline | tac | tail -n 1 | awk '{print $1}')"
      --tag $IMAGE_NAMESPACE/kape:latest .
    - docker push $IMAGE_NAMESPACE/kape:latest
  tags:
    - docker
  retry: 1
  allow_failure: true
Zamil Majdy's avatar
Zamil Majdy committed
114
  only:
115
    - master