57 lines
1.3 KiB
YAML
57 lines
1.3 KiB
YAML
stages:
|
|
- build
|
|
- docker
|
|
|
|
variables:
|
|
NODE_VERSION: "20"
|
|
|
|
cache:
|
|
key: "$CI_COMMIT_REF_SLUG"
|
|
paths:
|
|
- ~/.npm/
|
|
|
|
build:
|
|
stage: build
|
|
image: alpine:latest
|
|
before_script:
|
|
- apk update && apk add git tar nodejs npm
|
|
- npm ci
|
|
script:
|
|
- npm run build
|
|
- npx semantic-release
|
|
- find . -not -path "./node_modules/*" -type f -print0 | xargs -0 tar -czvf build-artifacts.tar.gz
|
|
artifacts:
|
|
paths:
|
|
- build-artifacts.tar.gz
|
|
only:
|
|
- merge_requests
|
|
- pushes
|
|
- web
|
|
|
|
docker:
|
|
stage: docker
|
|
dependencies:
|
|
- build
|
|
image:
|
|
name: gcr.io/kaniko-project/executor:v1.14.0-debug
|
|
entrypoint: [""]
|
|
script:
|
|
- tar -xzvf build-artifacts.tar.gz
|
|
- |
|
|
# If pipeline runs on the default branch: Set tag to "latest"
|
|
if test "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH"; then
|
|
tag="latest"
|
|
# If pipeline is a tag pipeline, set tag to the git commit tag
|
|
elif test -n "$CI_COMMIT_TAG"; then
|
|
tag="$CI_COMMIT_TAG"
|
|
# Else set the tag to the git commit sha
|
|
else
|
|
tag="$CI_COMMIT_SHA"
|
|
fi
|
|
- |
|
|
- /kaniko/executor
|
|
--context "${CI_PROJECT_DIR}"
|
|
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
|
|
--destination "${CI_REGISTRY_IMAGE}:${tag}"
|
|
# only:
|
|
# - tags
|