Select Git revision
.gitlab-ci.yml 2.15 KiB
image: node:16-alpine
stages:
- test
- build
- deploy
- release
# Prevent detached merge request pipelines
# https://docs.gitlab.com/ee/ci/merge_request_pipelines/
# Those do not run the environment on_stop jobs when MRs are closed/merged
# or when branches get deleted, unlike branch pipelines.
workflow:
rules:
- if: '$CI_MERGE_REQUEST_ID'
when: never
- when: always
before_script:
- npm ci
lint:
stage: test
script:
- npm run lint
audit:
stage: test
script:
- npm audit --parseable
allow_failure: true
build-webext:
stage: build
# Ignore frontend-audit to speed up CI builds
needs:
- lint
artifacts:
paths:
- dist-ext
expire_in: 2 weeks
script:
- npm run build-ext
build-lib:
stage: build
# Ignore frontend-audit to speed up CI builds
needs:
- lint
artifacts:
paths:
- dist-lib
expire_in: 2 weeks
script:
- npm run build-lib
# Only deploy branches on surge
rules:
- if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "master"'
when: on_success
- when: never
.surge:
stage: deploy
environment:
name: ${CI_COMMIT_REF_SLUG}
before_script:
- npm install -g surge
deploy-surge:
extends: .surge
dependencies:
- build-lib
# Only deploy branches on surge
rules:
- if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "master"'
when: on_success
- when: never
environment:
url: https://${CI_COMMIT_REF_SLUG}-keyboardteklia.surge.sh
on_stop: stop-surge
script:
- surge dist-lib ${CI_ENVIRONMENT_URL}
stop-surge:
extends: .surge
# Only deploy branches on surge
rules:
- if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "master"'
when: manual
allow_failure: true
- when: never
# Do not try to checkout the branch if it was deleted
variables:
GIT_STRATEGY: none
environment:
action: stop
script:
- surge teardown ${CI_ENVIRONMENT_URL}
release-npm:
stage: release
dependencies:
- build-lib
# Publish only on tags
only:
- tags
before_script:
- echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
script:
- npm publish --access public