.gitlab-ci.yml 1.85 KB
Newer Older
1 2
image: ebiwd/alpine-ssh:3.6

Peter Walter's avatar
Peter Walter committed
3
#project specific variables can be defined here, or overridden project settings
Peter Walter's avatar
Peter Walter committed
4 5
variables:
# do not define here, put in project variables
6 7 8 9 10
  SSH_OWNER_ID: wd_drupl
  SSH_APACHE_ID: w3_wd01
  # set secrets in Settings -> Pipelines -> Secret Variables
  SSH_WD_DRUPL: secret-key
  SSH_W3_WD01: secret-key
11

Peter Walter's avatar
Peter Walter committed
12 13
stages:
  - build
14
  - test
Peter Walter's avatar
Peter Walter committed
15
  - deploy
16
  - validate
Peter Walter's avatar
Peter Walter committed
17 18

build:
19
  stage: build
20
  image: ebiwd/node-bower-gulp:10
Peter Walter's avatar
Peter Walter committed
21 22
  tags:
    - docker
Peter Walter's avatar
Peter Walter committed
23
  script:
Ken Hawkins's avatar
Ken Hawkins committed
24
    - npm install
Peter Walter's avatar
Peter Walter committed
25
    - gulp
Peter Walter's avatar
Peter Walter committed
26 27 28
  cache:
    paths:
      - node_modules
Peter Walter's avatar
Peter Walter committed
29 30 31 32
  artifacts:
    paths:
      - dist

33 34
test:
  stage: test
Peter Walter's avatar
Peter Walter committed
35 36
  tags:
    - docker
37 38
  script:
    # test .htaccess has been generated
39
    - if [ ! -f ${CI_PROJECT_DIR}/dist/.htaccess ]; then echo "Missing .htaccess"; exit 1; fi
40 41 42
    # test index.html has been generated
    - if [ ! -f ${CI_PROJECT_DIR}/dist/index.html ]; then echo "Missing index.html"; exit 1; fi

Sandeep Kadam's avatar
Sandeep Kadam committed
43 44
# setup ssh keys
.deploy_template: &deploy
45
  stage: deploy
Peter Walter's avatar
Peter Walter committed
46 47
  tags:
    - docker
Sandeep Kadam's avatar
Sandeep Kadam committed
48 49 50 51
  before_script:
    - add-ssh-key ${SSH_OWNER_ID} "${SSH_WD_DRUPL}" ${SSH_APACHE_ID} "${SSH_W3_WD01}"
    - add-search-domain ebi.ac.uk
    - cd ${CI_PROJECT_DIR};
52 53 54
  dependencies:
    - build
  script:
Sandeep Kadam's avatar
Sandeep Kadam committed
55
    - bin/deploy ${ENVIRONMENT}
56

Sandeep Kadam's avatar
Sandeep Kadam committed
57
deploy-dev:
Peter Walter's avatar
Peter Walter committed
58
  stage: deploy
Peter Walter's avatar
Peter Walter committed
59 60
  only:
    - master
Sandeep Kadam's avatar
Sandeep Kadam committed
61 62 63
  variables:
    ENVIRONMENT: dev
  <<: *deploy
64

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
deploy-stage:
  stage: deploy
  only:
    - master
  variables:
    ENVIRONMENT: stage
  <<: *deploy

deploy-prod:
  stage: deploy
  only:
    - tags
  variables:
    ENVIRONMENT: prod
  <<: *deploy

81 82 83
validate_dev:
  stage: validate
  script:
Sandeep Kadam's avatar
Sandeep Kadam committed
84
    - set -a; source ${CI_PROJECT_DIR}/.env; set +a;
85
    - curl -L ${DEV_SITE_URL} | cmp ${CI_PROJECT_DIR}/dist/index.html -
86
  only:
87 88 89 90 91
    - master

validate_prod:
  stage: validate
  script:
92
    - set -a; source ${CI_PROJECT_DIR}/.env; set +a;
93
    - curl -L ${PROD_SITE_URL} | cmp ${CI_PROJECT_DIR}/dist/index.html -
94
  only:
95
    - tags