---
kind: pipeline
type: docker
name: deploy_image

steps:
  - name: pull-scripts
    image: alpine/git
    commands:
      - git clone https://gitea.alexlebens.net/alexlebens/DeploymentScripts.git

  - name: docker-cron
    image: plugins/docker
    settings:
      repo: ps03fd.alexlebens.net:5000/droneimage
      registry: ps03fd.alexlebens.net:5000
      insecure: true
      dockerfile: ./Dockerfile
      tags: latest
    when:
      event:
        - cron
      cron:
        include:
          - nightly

  - name: docker-main
    image: plugins/docker
    settings:
      repo: ps03fd.alexlebens.net:5000/droneimage
      registry: ps03fd.alexlebens.net:5000
      insecure: true
      dockerfile: ./Dockerfile
      tags: latest
    when:
      branch:
        - main

  - name: Nofification > Discord | Build - Success
    image: appleboy/drone-discord
    settings:
      webhook_id:
        from_secret: discord_webhook_id
      webhook_token:
        from_secret: discord_webhook_token
      username: DroneCI - ps03fd
      message: Succeeded building Drone Image
    when:
      status:
        - sucess

  - name: Nofification > Discord | Build - Failure
    image: appleboy/drone-discord
    settings:
      webhook_id:
        from_secret: discord_webhook_id
      webhook_token:
        from_secret: discord_webhook_token
      username: DroneCI - ps03fd
      message: Failed building Drone Image
    when:
      status:
        - failure
