.gitlab-ci.yml 4.41 KB
Newer Older
Sam Galson's avatar
Sam Galson committed
1 2 3 4
variables:
  IMAGE_NAME: xpub
  BASE_DOMAIN: gateway.xpub.semioticsquares.com
  CONFIGURATION_REPOSITORY: https://gitlab.coko.foundation/pubsweet/infra.git
Alf Eaton's avatar
Alf Eaton committed
5

Sam Galson's avatar
Sam Galson committed
6 7 8 9 10 11 12 13 14 15
stages:
  - build
  - test
  - review
  - staging
  - production
  - demo

build:
  image: docker:latest
Tamlyn Rhodes's avatar
Tamlyn Rhodes committed
16
  stage: build
Sam Galson's avatar
Sam Galson committed
17 18 19 20
  script:
    - docker version
    - docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
    - echo "Ignore warning! Cannot perform an interactive login from a non TTY device"
Sam Galson's avatar
Sam Galson committed
21
    - docker build -t $DOCKERHUB_USERNAME/$IMAGE_NAME:$CI_COMMIT_SHA .
Sam Galson's avatar
Sam Galson committed
22
    - docker push $DOCKERHUB_USERNAME/$IMAGE_NAME:$CI_COMMIT_SHA
Alf Eaton's avatar
Alf Eaton committed
23

Yannis Barlas's avatar
Yannis Barlas committed
24
lint:
Sam Galson's avatar
Sam Galson committed
25 26
  image: $DOCKERHUB_USERNAME/$IMAGE_NAME:$CI_COMMIT_SHA
  stage: test
Sam Galson's avatar
Sam Galson committed
27 28 29 30 31
  variables:
    GIT_STRATEGY: none
  script:
    - cd ${HOME}
    - npm run lint
Alf Eaton's avatar
Alf Eaton committed
32

Tamlyn Rhodes's avatar
Tamlyn Rhodes committed
33
test:
Sam Galson's avatar
Sam Galson committed
34 35
  image: $DOCKERHUB_USERNAME/$IMAGE_NAME:$CI_COMMIT_SHA
  stage: test
Sam Galson's avatar
Sam Galson committed
36 37 38 39 40
  variables:
    GIT_STRATEGY: none
  script:
    - cd ${HOME}
    - npm run test
Alf Eaton's avatar
Alf Eaton committed
41

Sam Galson's avatar
Sam Galson committed
42 43 44 45 46
# -----------------------------------------------
# xpub-collabra ---------------------------------
# -----------------------------------------------

review:xpub-collabra:
Sam Galson's avatar
Sam Galson committed
47
  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
48 49 50 51 52 53 54 55 56
  stage: review
  variables:
    PACKAGE_NAME: xpub-collabra
    FORCE_FRESH_DB: "yes"
  environment:
    name: $PACKAGE_NAME/review/$CI_COMMIT_REF_NAME
    # !! kube-lego will fail if domain > 64 chars
    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
    on_stop: stop_review:xpub-collabra
57 58
  except:
  - master
Sam Galson's avatar
Sam Galson committed
59 60 61 62 63
  script:
    - source deploy.sh
    - create_deployment

stop_review:xpub-collabra:
Sam Galson's avatar
Sam Galson committed
64
  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
65 66 67 68 69 70 71 72
  stage: review
  variables:
    PACKAGE_NAME: xpub-collabra
    GIT_STRATEGY: none
  environment:
    name: $PACKAGE_NAME/review/$CI_COMMIT_REF_NAME
    action: stop
  when: manual
Sam Galson's avatar
Sam Galson committed
73 74
  except:
  - master
Sam Galson's avatar
Sam Galson committed
75 76 77 78 79 80
  script:
    - source deploy.sh
    - delete_deployment


staging:xpub-collabra:
Sam Galson's avatar
Sam Galson committed
81
  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
82 83 84 85 86 87 88 89 90 91 92 93 94
  stage: staging
  variables:
    PACKAGE_NAME: xpub-collabra
  environment:
    name: $PACKAGE_NAME/staging
    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
  only:
  - master
  script:
    - source deploy.sh
    - create_deployment

production:xpub-collabra:
Sam Galson's avatar
Sam Galson committed
95
  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109
  stage: production
  variables:
    PACKAGE_NAME: xpub-collabra
  environment:
    name: $PACKAGE_NAME/production
    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
  when: manual
  only:
  - master
  script:
    - source deploy.sh
    - create_deployment

demo:xpub-collabra:
Sam Galson's avatar
Sam Galson committed
110
  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
  stage: demo
  variables:
    PACKAGE_NAME: xpub-collabra
  environment:
    name: $PACKAGE_NAME/demo
    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
  when: manual
  script:
    - source deploy.sh
    - create_deployment

# -----------------------------------------------
# xpub-ui ---------------------------------------
# -----------------------------------------------

#review:xpub-ui:
Sam Galson's avatar
Sam Galson committed
127
#  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
128 129 130 131 132 133 134 135
#  stage: review
#  variables:
#    PACKAGE_NAME: xpub-ui
#  environment:
#    name: $PACKAGE_NAME/review/$CI_COMMIT_REF_NAME
#    # !! kube-lego will fail if domain > 64 chars
#    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
#    on_stop: stop_review:xpub-ui
136 137
#  except:
#  - master
Sam Galson's avatar
Sam Galson committed
138 139 140 141 142
#  script:
#    - source deploy.sh
#    - create_deployment
#
#stop_review:xpub-ui:
Sam Galson's avatar
Sam Galson committed
143
#  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
144 145 146 147 148 149 150 151 152 153 154 155 156
#  stage: review
#  variables:
#    PACKAGE_NAME: xpub-ui
#    GIT_STRATEGY: none
#  when: manual
#  environment:
#    name: $PACKAGE_NAME/review/$CI_COMMIT_REF_NAME
#    action: stop
#  script:
#    - source deploy.sh
#    - delete_deployment
#
#staging:xpub-ui:
Sam Galson's avatar
Sam Galson committed
157
#  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
158 159 160 161 162 163 164 165 166 167 168 169 170
#  stage: staging
#  variables:
#    PACKAGE_NAME: xpub-ui
#  environment:
#    name: $PACKAGE_NAME/staging
#    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
#  only:
#  - master
#  script:
#    - source deploy.sh
#    - create_deployment
#
#production:xpub-ui:
Sam Galson's avatar
Sam Galson committed
171
#  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
172 173 174 175 176 177 178 179 180 181 182 183 184 185
#  stage: production
#  variables:
#    PACKAGE_NAME: xpub-ui
#  environment:
#    name: $PACKAGE_NAME/production
#    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
#  when: manual
#  only:
#  - master
#  script:
#    - source deploy.sh
#    - create_deployment
#
#demo:xpub-ui:
Sam Galson's avatar
Sam Galson committed
186
#  image: pubsweet/deployer:latest
Sam Galson's avatar
Sam Galson committed
187 188 189 190 191 192 193 194 195 196 197
#  stage: demo
#  variables:
#    PACKAGE_NAME: xpub-ui
#  environment:
#    name: $PACKAGE_NAME/demo
#    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
#  when: manual
#  script:
#    - source deploy.sh
#    - create_deployment
#