stages: - build - cleanup_build - deploy - cleanup build_job: stage: build script: - npm install - npm run build - npm run test tags: - javascript except: - tags artifacts: paths: - dist expire_in: 30 min cleanup_build_job: stage: cleanup_build script: - rm -rf node_modules - rm -rf dist when: on_failure pages: stage: deploy environment: staging except: - tags - master script: - mv dist public artifacts: paths: - public dependencies: - build_job production: stage: deploy environment: production only: - master script: - if [[ -z "${WWW_DEPLOY_ROOT_PRODUCTION}" ]] ; then echo "WWW_DEPLOY_ROOT_PRODUCTION is not set" ; exit 1 ; fi - if [[ ! -d "${WWW_DEPLOY_ROOT_PRODUCTION}" ]] ; then mkdir -p "${WWW_DEPLOY_ROOT_PRODUCTION}" || die "Failed to create target directory for deployment!" ; fi - cp dist/* "${WWW_DEPLOY_ROOT_PRODUCTION}" cleanup_job: stage: cleanup script: - rm -rf node_modules when: always