Commit c5c7b72d authored by Yannick Li's avatar Yannick Li
Browse files

CI: Setup automatic website deployment

parent 074c5d4a
Pipeline #242094 passed with stages
in 0 seconds
......@@ -3,6 +3,8 @@ image: node:14.16.0
stages:
- build
- test
- predeploy
- deploy
cache: &global_cache # per-branch cache
key: ${CI_COMMIT_REF_SLUG}
......@@ -60,4 +62,86 @@ test:
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
artifacts:
paths:
- coverage/
- collaborative/coverage/
# Filter out node_modules from build artifacts to speed up deploy.
# Gitlab 13.10 will allow to use multiple cache instead.
pre-deploy:
stage: predeploy
rules:
- if: "$CI_COMMIT_BRANCH"
# use only artifacts from build job
dependencies:
- build
# cache is not needed: don't download
cache: {}
# don't download repository content
variables:
GIT_STRATEGY: none
artifacts:
paths:
- collaborative/build/
# script is required
script:
- echo Exporting collaborative/build/…
deploy_review:
stage: deploy
rules:
- if: "$CI_COMMIT_BRANCH"
tags:
- webserver
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://demo.concordant.io/c-sudoku_${CI_ENVIRONMENT_SLUG}/
on_stop: stop_review
# use only artifacts from pre-deploy job
dependencies:
- pre-deploy
# cache and repository art not needed: don't download
cache: {}
variables:
GIT_STRATEGY: none
script:
- rm -rf /var/www/demo.concordant.io/html/c-sudoku_${CI_ENVIRONMENT_SLUG}
- mv collaborative/build /var/www/demo.concordant.io/html/c-sudoku_${CI_ENVIRONMENT_SLUG}
stop_review:
stage: deploy
rules:
- if: "$CI_COMMIT_BRANCH"
when: manual
allow_failure: true
tags:
- webserver
environment:
name: review/$CI_COMMIT_REF_NAME
action: stop
# artifacts, cache and repository are not needed: don't download
dependencies: []
cache: {}
variables:
GIT_STRATEGY: none
script:
- rm -rf /var/www/demo.concordant.io/html/c-sudoku_${CI_ENVIRONMENT_SLUG}
deploy_live:
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: manual
tags:
- webserver
environment:
name: live
url: https://demo.concordant.io/c-sudoku/
# use only artifacts from pre-deploy job
dependencies:
- pre-deploy
# cache and repository art not needed: don't download
cache: {}
variables:
GIT_STRATEGY: none
script:
- rm -rf /var/www/demo.concordant.io/html/c-sudoku
- mv collaborative/build /var/www/demo.concordant.io/html/c-sudoku
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment