Last active
April 17, 2024 19:35
-
-
Save zerda/1ba1ad8dc0ae31fe5b2d65eda03c4819 to your computer and use it in GitHub Desktop.
Gitlab CI for front-end project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: node:6-alpine | |
cache: | |
key: "$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME" | |
paths: | |
- node_modules/ | |
- yarn_cache/ | |
stages: | |
- setup | |
- test | |
- build | |
- deploy | |
init: | |
stage: setup | |
script: | |
- yarn config set registry https://registry.npm.taobao.org | |
- export npm_config_node_sqlite3_binary_host_mirror=https://npm.taobao.org/mirrors/ | |
- yarn --prefer-offline --no-progress --non-interactive --frozen-lockfile --cache-folder ./yarn_cache | |
lint: | |
stage: test | |
script: | |
- yarn run lint -- --quiet | |
unit_test_cov: | |
stage: test | |
script: | |
- yarn run cover | |
artifacts: | |
paths: | |
- coverage | |
expire_in: 1 day | |
.build: &build_template | |
stage: build | |
script: | |
- yarn run build --release | |
develop_build: | |
<<: *build_template | |
only: | |
- branches | |
except: | |
- master | |
artifacts: | |
expire_in: 1 day | |
paths: | |
- release/ | |
master_build: | |
<<: *build_template | |
only: | |
- master | |
- tags | |
artifacts: | |
expire_in: 1 month | |
paths: | |
- release/ | |
build_image: | |
stage: deploy | |
image: docker:latest | |
only: | |
- tags | |
script: | |
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY | |
- docker build -t $CI_REGISTRY_IMAGE:$CI_BUILD_TAG release/ | |
- docker push $CI_REGISTRY_IMAGE:$CI_BUILD_TAG | |
pages: | |
stage: deploy | |
dependencies: | |
- unit_test_cov | |
script: | |
- mkdir public | |
- mv coverage/lcov-report/ public/coverage | |
artifacts: | |
paths: | |
- public | |
expire_in: 1 day | |
only: | |
- develop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment