.gitlab-ci.yml 3.58 KB
Newer Older
David Burke's avatar
David Burke committed
1
image: registry.gitlab.com/dasch8/angular-ci:latest
2

3
variables:
4 5
  DOCKER_DRIVER: overlay2
  COMPOSE: docker-compose -f docker-compose.yml -f docker-compose.ci.yml
Saul Shanabrook's avatar
Saul Shanabrook committed
6

7 8
stages:
  - test
David Burke's avatar
David Burke committed
9
  - docker
10
  - deploy
11
  - pages
12

Saul Shanabrook's avatar
Saul Shanabrook committed
13
test:
14
  stage: test
David Burke's avatar
David Burke committed
15
  cache:
Saul Shanabrook's avatar
Saul Shanabrook committed
16
    paths:
David Burke's avatar
David Burke committed
17 18 19 20
      - node_modules/
  script:
    - yarn install
    - yarn run lint
David Burke's avatar
David Burke committed
21
    - yarn run test --progress false --single-run=true --watch=false --browsers=Chromium_CI
22

23 24
build-web-assets:
  stage: test
David Burke's avatar
David Burke committed
25 26 27
  cache:
    paths:
      - node_modules/
28
  script:
David Burke's avatar
David Burke committed
29 30
    - yarn install
    - yarn run build --prod --build-optimizer --progress false
31 32 33 34 35
  artifacts:
    paths:
      - dist/

build-ext-assets:
Saul Shanabrook's avatar
Saul Shanabrook committed
36
  stage: test
David Burke's avatar
David Burke committed
37 38 39
  cache:
    paths:
      - node_modules/
40
  script:
David Burke's avatar
David Burke committed
41
    - yarn install
42
    - ./set_version.sh
David Burke's avatar
David Burke committed
43
    - yarn run build:ext --prod --build-optimizer --progress false
44
    - find dist -type f -name "*.js" | xargs sed -i 's/([0,1],eval)("this")/undefined/g'
45
    - find dist -type f -name "*.js" | xargs sed -i 's/new Function(/(/g'
David Burke's avatar
David Burke committed
46 47
    - yarn run ext:lint
    - yarn run ext:build
48
    - mv web-ext-artifacts/*.zip web-ext-artifacts/passit.zip
49
    - mv dist dist-ext
David Burke's avatar
David Burke committed
50 51
  artifacts:
    paths:
52
      - web-ext-artifacts/
53
      - dist-ext/
Saul Shanabrook's avatar
Saul Shanabrook committed
54

55
build-push-docker:
David Burke's avatar
David Burke committed
56
  stage: docker
David Burke's avatar
David Burke committed
57 58 59
  image: registry.gitlab.com/passit/docker-compose
  services:
    - docker:dind
60
  dependencies:
61 62
    - build-ext-assets
    - build-web-assets
63 64
  only:
    - master
David Burke's avatar
David Burke committed
65
    - staging
Saul Shanabrook's avatar
Saul Shanabrook committed
66
    - dev
67
  script:
David Burke's avatar
David Burke committed
68 69
    - VERSION=$(cat package.json | grep version | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,\",]//g' | tr -d '[[:space:]]')
    - docker build -f Dockerfile.prod -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME} --build-arg PASSIT_VERSION=$VERSION .
70
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
71
    - docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}
David Burke's avatar
David Burke committed
72 73 74

deploy-staging:
  stage: deploy
David Burke's avatar
David Burke committed
75 76 77
  image: registry.gitlab.com/passit/docker-compose
  services:
    - docker:dind
David Burke's avatar
David Burke committed
78 79
  only:
    - staging
80 81 82
  environment:
    name: staging
    url: https://staging.passit.io
David Burke's avatar
David Burke committed
83 84 85
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
    - docker pull ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}
David Burke's avatar
David Burke committed
86
    - docker login -u ${OPENSHIFT_USER} -p ${OPENSHIFT_STAGING_KEY} https://${OPENSHIFT_REGISTRY}
David Burke's avatar
David Burke committed
87 88
    - docker tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME} ${OPENSHIFT_REGISTRY}/passit-staging/passit-frontend:staging
    - docker push ${OPENSHIFT_REGISTRY}/passit-staging/passit-frontend:staging
David Burke's avatar
David Burke committed
89

David Burke's avatar
David Burke committed
90
deploy-prod:
91
  stage: deploy
David Burke's avatar
David Burke committed
92 93 94
  image: registry.gitlab.com/passit/docker-compose
  services:
    - docker:dind
95 96 97 98
  only:
    - master
  when: manual
  environment:
David Burke's avatar
David Burke committed
99
    name: production
100 101 102 103
    url: https://app.passit.io
  script:
    - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
    - docker pull ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME}
David Burke's avatar
David Burke committed
104 105 106
    - docker login -u ${OPENSHIFT_USER} -p ${OPENSHIFT_PROD_KEY} https://${OPENSHIFT_REGISTRY}
    - docker tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME} ${OPENSHIFT_REGISTRY}/passit-prod/passit-frontend:master
    - docker push ${OPENSHIFT_REGISTRY}/passit-prod/passit-frontend:master
107

108 109 110 111 112 113 114 115 116 117 118 119
deploy-chrome-ext:
  stage: deploy
  dependencies:
    - build-ext-assets
  only:
    - master
  when: manual
  script:
    - apt-get update
    - apt-get -y install curl jq
    - bin/deploy_chrome.sh

120 121 122 123 124 125 126 127
deploy-firefox-ext:
  stage: deploy
  dependencies:
    - build-ext-assets
  only:
    - master
  when: manual
  script:
128
    - yarn install
129 130
    - yarn run ext:publish_firefox

Brendan Berkley's avatar
Brendan Berkley committed
131 132
pages:
  stage: pages
David Burke's avatar
David Burke committed
133 134 135
  cache:
    paths:
      - node_modules/
Brendan Berkley's avatar
Brendan Berkley committed
136
  script:
David Burke's avatar
David Burke committed
137 138
    - yarn install
    - yarn run compodoc-gitlab
Brendan Berkley's avatar
Brendan Berkley committed
139 140
  artifacts:
    paths:
Brendan Berkley's avatar
Brendan Berkley committed
141
    - public
Brendan Berkley's avatar
Brendan Berkley committed
142 143
  only:
    - master