.gitlab-ci.yml 2.85 KB
Newer Older
janis.streib's avatar
janis.streib committed
1
2
default:
    image: debian-buster:latest
janis.streib's avatar
janis.streib committed
3
before_script:
janis.streib's avatar
janis.streib committed
4
    ## dependencies
janis.streib's avatar
janis.streib committed
5
6
7
    
    - apt-get update -y
    - test -e  /etc/apt/sources.list.d/nodesource.list || curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
janis.streib's avatar
janis.streib committed
8
    - test -e  /etc/apt/sources.list.d/nodesource.list || echo 'deb https://deb.nodesource.com/node_15.x buster main' > /etc/apt/sources.list.d/nodesource.list
janis.streib's avatar
janis.streib committed
9
    - 'which npm || (apt-get update -y && apt-get install -y nodejs)'
janis.streib's avatar
janis.streib committed
10
    - 'which pip3 || (apt-get update -y && apt-get install -y python3-pip)'
janis.streib's avatar
janis.streib committed
11
    - pip3 install git+https://git.scc.kit.edu/scc-net/net-suite/api-generator.git#egg=net-api-generator
12
13
    - cd frontend/
    - cp netvs.config.js.example netvs.config.js
14
    - if [ $CI_JOB_STAGE != "deploy" ]; then npm install; fi
15
    - cd ..
janis.streib's avatar
janis.streib committed
16

janis.streib's avatar
janis.streib committed
17
18
19
stages:
    - build
    - lint
janis.streib's avatar
janis.streib committed
20
    - deploy
janis.streib's avatar
janis.streib committed
21
22
23
24
25

frontend-build:
    stage: build
    script:
        - cd frontend/
janis.streib's avatar
janis.streib committed
26
        - net-api-generator openapi > public/api.yml 
janis.streib's avatar
janis.streib committed
27
        - net-api-generator es-webpack 
janis.streib's avatar
janis.streib committed
28
29
        - npm run build
    artifacts:
30
        expire_in: 7 days
janis.streib's avatar
janis.streib committed
31
32
        paths:
            - frontend/dist/
33
            - frontend/src/api-services.gen/
34
    needs: []
janis.streib's avatar
janis.streib committed
35
36
37
38
39
40
frontend-lint:
    stage: lint
    script:
        - cd frontend/
        - npm run lint
    allow_failure: true
41
    needs: []
janis.streib's avatar
janis.streib committed
42

janis.streib's avatar
janis.streib committed
43
44
45
46
47
48
frontend-audit:
    stage: lint
    script:
        - cd frontend/
        - npm audit
    allow_failure: true
49
    needs: []
janis.streib's avatar
janis.streib committed
50

janis.streib's avatar
janis.streib committed
51
deploy_devel:
janis.streib's avatar
janis.streib committed
52
53
  stage: deploy
  script:
54
55
56
57
58
59
60
    - 'which ssh-agent || ( apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
janis.streib's avatar
janis.streib committed
61
    - ssh net-suite-devel@netvs-devel.scc.kit.edu "${CI_PIPELINE_ID}"
janis.streib's avatar
janis.streib committed
62
  environment:
janis.streib's avatar
janis.streib committed
63
64
    name: devel
    url: https://netvs-devel.scc.kit.edu
janis.streib's avatar
janis.streib committed
65
  only:
janis.streib's avatar
janis.streib committed
66
  - devel
janis.streib's avatar
FIXUP    
janis.streib committed
67
  needs: ["frontend-build"]
janis.streib's avatar
janis.streib committed
68
69
70
71
72
73
74
75
76
77
deploy_test:
  stage: deploy
  script:
    - 'which ssh-agent || ( apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
janis.streib's avatar
janis.streib committed
78
    - ssh www-net-suite@netvs-test.scc.kit.edu "${CI_PIPELINE_ID}"
janis.streib's avatar
janis.streib committed
79
80
81
82
83
  environment:
    name: test
    url: https://netvs-test.scc.kit.edu
  only:
  - master
janis.streib's avatar
FIXUP    
janis.streib committed
84
  needs: ["frontend-build"]
janis.streib's avatar
janis.streib committed
85
86
87
88
89
90
91
92
93
94
deploy_prod:
  stage: deploy
  script:
    - 'which ssh-agent || ( apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
janis.streib's avatar
janis.streib committed
95
    - ssh www-net-suite@netvs.scc.kit.edu "${CI_PIPELINE_ID}"
janis.streib's avatar
janis.streib committed
96
97
98
99
100
  environment:
    name: prod
    url: https://netvs.scc.kit.edu
  only:
  - master
janis.streib's avatar
FIXUP    
janis.streib committed
101
  needs: ["frontend-build"]