rubocop:
  image: registry.docker.com/library/ruby:3.4.2
  stage: test
  cache:
    paths:
      - vendor/bundle
  before_script:
    - ruby -v
    - bundle config set --local deployment true  # Install dependencies into ./vendor/bundle
    - bundle config set --local with test        # bundle install --with=test
    - bundle install -j $(nproc)
  script:
    - bundle exec rubocop

docker-image:
  image:
    name: gcr.io/kaniko-project/executor:v1.23.2-debug
    entrypoint: [""]
  stage: deploy
  variables:
    DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  script:
    - /kaniko/executor
      --context "${CI_PROJECT_DIR}"
      --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
      --destination "${DOCKER_IMAGE_NAME}"
  rules:
    - if: $CI_COMMIT_BRANCH
      exists:
        - Dockerfile