.gitlab-ci.yml 2.69 KB
Newer Older
Sam Galson's avatar
Sam Galson committed
1 2 3 4 5
variables:
  IMAGE_ORG: pubsweet
  IMAGE_NAME: pubsweet
  BASE_DOMAIN: gateway.ps.semioticsquares.com
  CONFIGURATION_REPOSITORY: https://gitlab.coko.foundation/pubsweet/deployment-config.git
6

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

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

25
lint:style:
Sam Galson's avatar
Sam Galson committed
26 27 28 29
  image: $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
  stage: test
  variables:
    GIT_STRATEGY: none
Jure's avatar
Jure committed
30
  script:
Sam Galson's avatar
Sam Galson committed
31
    - cd ${HOME}
Jure's avatar
Jure committed
32
    - npm run lint:style
33

34
lint:js:
Sam Galson's avatar
Sam Galson committed
35 36 37 38
  image: $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
  stage: test
  variables:
    GIT_STRATEGY: none
Jure's avatar
Jure committed
39
  script:
Sam Galson's avatar
Sam Galson committed
40
    - cd ${HOME}
Jure's avatar
Jure committed
41
    - npm run lint:js
42

43
test:
Sam Galson's avatar
Sam Galson committed
44 45 46 47
  image: $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
  stage: test
  variables:
    GIT_STRATEGY: none
Jure's avatar
Jure committed
48
  script:
Sam Galson's avatar
Sam Galson committed
49
    - cd ${HOME}
Sam Galson's avatar
Sam Galson committed
50
    - NODE_ENV=test npm run test
Jure's avatar
Jure committed
51

Sam Galson's avatar
Sam Galson committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
# -----------------------------------------------
# ui --------------------------------------------
# -----------------------------------------------

review:ui:
  image: xpub/deployer:latest
  stage: review
  variables:
    PACKAGE_NAME: ui
  environment:
    name: $PACKAGE_NAME/review/$CI_COMMIT_REF_NAME
    # !! kube-lego will fail if domain > 63 chars
    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
    on_stop: stop_review:ui
  except:
  - master
  script:
    - source deploy.sh
    - create_deployment

stop_review:ui:
  image: xpub/deployer:latest
  stage: review
  variables:
    PACKAGE_NAME: ui 
    GIT_STRATEGY: none
  environment:
    name: $PACKAGE_NAME/review/$CI_COMMIT_REF_NAME
    action: stop
  when: manual
  except:
  - master
  script:
    - source deploy.sh
Sam Galson's avatar
Sam Galson committed
86
    - delete_deployment_no_db
Jure's avatar
Jure committed
87

Sam Galson's avatar
Sam Galson committed
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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
staging:ui:
  image: xpub/deployer:latest
  stage: staging
  variables:
    PACKAGE_NAME: ui
  environment:
    name: $PACKAGE_NAME/staging
    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
  only:
  - master
  script:
    - source deploy.sh
    - create_deployment

production:ui:
  image: xpub/deployer:latest
  stage: production
  variables:
    PACKAGE_NAME: ui
  environment:
    name: $PACKAGE_NAME/production
    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
  when: manual
  only:
  - master
  script:
    - source deploy.sh
    - create_deployment

demo:ui:
  image: xpub/deployer:latest
  stage: demo
  variables:
    PACKAGE_NAME: ui
  environment:
    name: $PACKAGE_NAME/demo
    url: "https://${CI_ENVIRONMENT_SLUG}.${BASE_DOMAIN}"
  when: manual
  script:
    - source deploy.sh
    - create_deployment