Skip to content

Instantly share code, notes, and snippets.

@aweffr
Forked from zerda/.gitlab-ci.yml
Created May 25, 2022 07:24
Show Gist options
  • Save aweffr/4014b551e30bcfeac12f897f254bde16 to your computer and use it in GitHub Desktop.
Save aweffr/4014b551e30bcfeac12f897f254bde16 to your computer and use it in GitHub Desktop.
Gitlab CI for front-end project
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