Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.09 KiB
Newer Older
Reiter, Christoph's avatar
Reiter, Christoph committed
image: registry.gitlab.tugraz.at/dbp/web-components/toolkit/main:v1
cache:
  key: ${CI_PROJECT_PATH}
  paths:
    - _yarn_cache
Bekerle, Patrizio's avatar
Bekerle, Patrizio committed

before_script:
  - yarn config set cache-folder "$CI_PROJECT_DIR/_yarn_cache"
stages:
  - test
  - deploy

test:
  stage: test
  script:
    - yarn install --frozen-lockfile
    - yarn check --integrity
linting:
  stage: test
  script:
    - yarn install --frozen-lockfile
publish:
  stage: deploy
  only:
    refs:
      - deploy
      - master
    # https://www.npmjs.com/settings/dbp-deploy/tokens
    # NPM_TOKEN needs to be a "Publish" token with 2FA disabled!
    # "Automation" tokens don't work with lerna (even if they would work with "npm publish")
    - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > ~/.npmrc
    - yarn install --frozen-lockfile
    - yarn run build
    - yarn run publish

.deploy_defaults: &deploy_defaults
  except:
    - schedules
  stage: deploy
  script:
    # Add ssh key
    - mkdir -p ~/.ssh
    - echo "${DEPLOY_KEY}" | tr -d '\r' > ~/.ssh/id_rsa
    - chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_rsa
    - ssh-keyscan -t rsa "${DEPLOY_HOST}" >> ~/.ssh/known_hosts
    # Deploy
    - cd toolkit-showcase
    - dep deploy --file ./../.gitlab-ci/deploy.php "${CI_ENVIRONMENT_NAME}"
    - echo "Deployed to ${CI_ENVIRONMENT_URL}"
    # Simple health check
    - curl --max-time 10 --retry 3 --output /dev/null --silent --show-error --fail --location "${CI_ENVIRONMENT_URL}"

deploy_demo:
  only:
    refs:
      - demo
  environment:
    name: demo
Reiter, Christoph's avatar
Reiter, Christoph committed
    url: https://dbp-demo.tugraz.at/apps/demo
  variables:
    DEPLOY_HOST: vpu01-demo.tugraz.at
    DEPLOY_KEY: "$DEPLOY_SSH_KEY"
  <<: *deploy_defaults

deploy_development:
  only:
    refs:
      - master
  environment:
    name: development
Reiter, Christoph's avatar
Reiter, Christoph committed
    url: https://dbp-dev.tugraz.at/apps/demo
  variables:
    DEPLOY_HOST: mw01-dev.tugraz.at
    DEPLOY_KEY: "$DEPLOY_SSH_KEY"
  <<: *deploy_defaults

Bekerle, Patrizio's avatar
Bekerle, Patrizio committed
  only:
    refs:
      - master
  variables:
    E2E_PROJECT: toolkit-showcase
  stage: e2e
  trigger:
    project: dbp/e2e-tests
    strategy: depend