auth/.gitlab-ci.yml

59 lines
1.6 KiB
YAML
Raw Permalink Normal View History

2023-01-10 14:28:19 +00:00
image: docker:20.10.22
stages:
2023-04-05 10:09:36 +00:00
- test
2023-02-09 13:20:05 +00:00
- build
2023-01-10 14:28:19 +00:00
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
2023-04-05 10:09:36 +00:00
##############
# TEST STAGE #
##############
2023-01-10 14:28:19 +00:00
2023-04-05 10:09:36 +00:00
test:
stage: test
image: docker/compose:latest
variables:
DOCKER_TLS_CERTDIR: ''
services:
- docker:dind
script:
- docker-compose -f docker-compose.ci.tools.yml -p auth-tools --env-file ci/.env.ci up -d
- sh ci/wait-up.sh
- docker-compose -f docker-compose.ci.service.yml -p auth-service --env-file ci/.env.ci up -d
- docker exec -t v3-auth-api sh -c "npm run test:integration:ci"
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
2023-02-09 13:20:05 +00:00
###############
# BUILD STAGE #
###############
build:
stage: build
image: docker:20.10.22
variables:
2023-03-30 08:28:20 +00:00
DOCKER_TLS_CERTDIR: ''
2023-02-09 13:20:05 +00:00
services:
- docker:dind
before_script:
2023-04-04 09:59:05 +00:00
- echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
2023-02-09 13:20:05 +00:00
script:
2023-04-04 10:27:40 +00:00
- export VERSION=$(docker run --rm -v "$PWD":/usr/src/app:ro -w /usr/src/app node:slim node -p "require('./package.json').version")
2023-04-04 09:59:05 +00:00
- docker pull $CI_REGISTRY_IMAGE:latest || true
- >
docker build
--pull
--cache-from $CI_REGISTRY_IMAGE:latest
2023-04-04 10:43:27 +00:00
--tag $CI_REGISTRY_IMAGE:$VERSION
--tag $CI_REGISTRY_IMAGE:latest
2023-04-04 09:59:05 +00:00
.
2023-04-05 10:01:27 +00:00
- docker push $CI_REGISTRY_IMAGE:$VERSION
- docker push $CI_REGISTRY_IMAGE:latest
2023-02-09 13:20:05 +00:00
only:
- main