---
include:
  - project: shore/ci-stuff
    file: templates/pre-commit.yml
  - project: shore/ci-stuff
    file: templates/docker.yml
  - project: shore/ci-stuff
    file: templates/notify.yml

build:
  extends: .compose-build
  tags: &tags [ns4.shore.co.il]
  rules:
    - if: $CI_PIPELINE_SOURCE != "schedule"

pull:
  extends: .compose-pull
  tags: *tags
  rules:
    - if: $CI_PIPELINE_SOURCE != "schedule"

run:
  rules:
    - if: $CI_PIPELINE_SOURCE != "schedule"
      when: manual
  extends: .compose-run
  tags: *tags


backup:
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
  stage: deploy
  tags: [host01.shore.co.il]
  image: docker.io/library/docker:20.10
  before_script:
    - >-
      docker build
      --tag registry.shore.co.il/registry-backup
      --pull
      backup
  script:
    - >-
      docker run
      --volume /var/backups/registry:/var/backups/registry
      --user nobody
      --rm
      registry.shore.co.il/registry-backup
      backup registry.shore.co.il /var/backups/registry
  retry:
    max: 2
  timeout: 3h
