version: v1.0
name: Confd

execution_time_limit:
  hours: 4

agent:
  machine:
    type: e1-standard-2
    os_image: ubuntu1804

global_job_config:
  secrets:
  - name: docker-hub
  prologue:
    commands:
      - echo $DOCKERHUB_PASSWORD | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
      - checkout

blocks:
  - name: 'CI'
    dependencies: []
    task:
      jobs:
        - name: CI
          execution_time_limit:
            minutes: 60
          commands:
            - make ci

  - name: Trigger pin updates
    dependencies: []
    skip:
      when: "(branch != 'master') and (branch !~ '^release-v\d*\.\d*')"
    task:
      secrets:
        - name: semaphore-api
      jobs:
        - name: Trigger pin updates
          execution_time_limit:
            minutes: 5
          commands:
            - checkout
            - make semaphore-run-auto-pin-update-workflows

promotions:
  # Run the pin update process in case there were a backlog of pin update requests
  - name: Update Pins
    pipeline_file: update_pins.yml
    auto_promote:
      # If the block has passed and the branch is for master or a release branch then run the pin updates. Note that
      # this doesn't try to restrict which release branches, as the presence of this auto promotion code means that
      # it can handle updating the pins in this fashion.
      when: "(result = 'passed') and ((branch = 'master') or (branch =~ '^release-v\d*\.\d*'))"
