diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fffed50ef5b03df01f979b61ef0417cfffc0c9c3..60ce80f45bc22417ea997a1d70086d9d31484474 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,51 +1,41 @@ -# This is a sample GitLab CI/CD configuration file that should run without any modifications. -# It demonstrates a basic 3 stage CI/CD pipeline. Instead of real tests or scripts, -# it uses echo commands to simulate the pipeline execution. -# -# A pipeline is composed of independent jobs that run scripts, grouped into stages. -# Stages run in sequential order, but jobs within stages run in parallel. -# -# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages -# -# You can copy and paste this template into a new `.gitlab-ci.yml` file. -# You should not add this template to an existing `.gitlab-ci.yml` file by using the `include:` keyword. -# -# To contribute improvements to CI/CD templates, please follow the Development guide at: -# https://docs.gitlab.com/ee/development/cicd/templates.html -# This specific template is located at: -# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml - default: image: node:16.16.0 +variables: + # enable docker buildkit. Used with `BUILDKIT_INLINE_CACHE=1` below + DOCKER_BUILDKIT: 1 + DOCKER_TLS_CERTDIR: '/certs' + IMAGE_TEST: $CI_REGISTRY_IMAGE/test:latest + #IMAGE_CYPRESS: $CI_REGISTRY_IMAGE/cypress:latest + IMAGE_DEPLOY: $CI_REGISTRY_IMAGE/deploy:latest + stages: - - lint - - test - build + - misc - deploy cache: paths: - ~/.cache -variables: - DOCKER_DRIVER: overlay2 -lint:commit: - stage: lint +.base: + image: docker:latest + services: + - docker:dind + before_script: + - docker --version + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY" + +build:builder: + extends: .base + stage: build script: - - npm install - - echo "${CI_COMMIT_MESSAGE}" | npx commitlint + - docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from "$IMAGE_TEST" --target builder -t "$IMAGE_TEST" . + - docker push "$IMAGE_TEST" -deploy_staging: - stage: deploy - environment: staging - except: - - main +build:deployimage: + extends: .base + stage: misc + needs: ['build:builder'] script: - - npm install --global vercel - - vercel pull --yes --environment=preview --token=$VERCEL_TOKEN - - vercel build --token=$VERCEL_TOKEN - - vercel deploy --prebuilt --token=$VERCEL_TOKEN - rules: - - if: $CI_COMMIT_BRANCH == "develop" - when: never - - if: $CI_COMMIT_BRANCH + - docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from "$IMAGE_DEPLOY" --cache-from "$IMAGE_TEST" --cache-from "$IMAGE_CYPRESS" -t "$IMAGE_DEPLOY" . + - docker push "$IMAGE_DEPLOY"