version: v1.0
name: Publish guardian images
agent:
  machine:
    type: f1-standard-2
    os_image: ubuntu2204

execution_time_limit:
  minutes: 60

global_job_config:
  env_vars:
    - name: DEV_REGISTRIES
      value: quay.io/calico docker.io/calico
  secrets:
    - name: docker
    - name: quay-robot-calico+semaphoreci
  prologue:
    commands:
      - checkout
      # Semaphore is doing shallow clone on a commit without tags.
      # unshallow it for GIT_VERSION:=$(shell git describe --tags --dirty --always)
      - retry git fetch --unshallow
      - echo $DOCKER_TOKEN | docker login --username "$DOCKER_USER" --password-stdin
      - echo $QUAY_TOKEN | docker login --username "$QUAY_USER" --password-stdin quay.io
      - export BRANCH_NAME=$SEMAPHORE_GIT_BRANCH

blocks:
  - name: Publish guardian images and multi-arch manifests
    dependencies: []
    skip:
      when: "branch !~ '.+'"
    task:
      jobs:
        - name: Linux multi-arch
          commands:
            - if [ -z "${SEMAPHORE_GIT_PR_NUMBER}" ]; then make -C guardian cd push-manifests-with-tag CONFIRM=true; fi
