Skip to content

Instantly share code, notes, and snippets.

@mikhno-s
Created June 14, 2017 19:24
Show Gist options
  • Save mikhno-s/c22a7f3de89ba7a632d168dc8a562513 to your computer and use it in GitHub Desktop.
Save mikhno-s/c22a7f3de89ba7a632d168dc8a562513 to your computer and use it in GitHub Desktop.
Build and containeraized node.js app with gitlab-ci
image: node:7
stages:
- install_dependencies
- build
- tests
- publish
- deploy
install:dependencies:
stage: install_dependencies
cache:
paths:
- node_modules/
tags:
- docker
script:
- npm install --loglevel warn
artifacts:
paths:
- node_modules/
only:
- /^v?\d+\.\d+\.\d+(|\-.+)$/
build:
stage: build
tags:
- docker
script:
- npm run build
- grep '"version"' package.json | xargs | sed s/,// >> build/version-fe.txt
- date >> build/version.txt
dependencies:
- install:dependencies
artifacts:
paths:
- build/
only:
- /^v?\d+\.\d+\.\d+\-dev$/
test:unit:
stage: tests
tags:
- docker
script:
- npm run test
dependencies:
- install:dependencies
allow_failure: true
only:
- /^v?\d+\.\d+\.\d+(|\-.+)$/
publish:docker_registry:
stage: publish
tags:
- shell
- duss
script:
- docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" "$CI_REGISTRY"
- docker build --pull --rm -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
only:
- /^v?\d+\.\d+\.\d+(|\-.+)$/
dependencies:
- build
Deploy:
stage: deploy
script:
- curl -X POST -F token=$deploy_token -F "ref=master" -F "variables[version]=$CI_COMMIT_REF_NAME" https://gitlab.com/api/v4/projects/423/trigger/pipeline
only:
- /^v?\d+\.\d+\.\d+(|\-.+)$/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment