---
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
kind: pipeline
type: docker
name: qa

trigger:
  event:
    - push
    - pull_request
  branch:
    - main

steps:
  - name: reuse
    image: fsfe/reuse
  - name: lint
    image: node:20
    commands:
      - npm ci
      - npm run lint

---
kind: pipeline
type: docker
name: build

trigger:
  event:
    - push
  branch:
    - main

depends_on:
  - qa

steps:
  - name: docker-publish
    image: plugins/docker
    settings:
      registry: registry.wtf-eg.net
      repo: registry.wtf-eg.net/ki-frontend
      target: ki-frontend
      auto_tag: true
      username:
        from_secret: "docker_username"
      password:
        from_secret: "docker_password"

---
kind: pipeline
type: docker
name: deploy

trigger:
  event:
    - push
  branch:
    - main

depends_on:
  - build

steps:
  - name: deploy-dev
    image: appleboy/drone-ssh
    settings:
      host:
        - dev01.wtf-eg.net
      username: drone_deployment
      key:
        from_secret: "dev01_deployment_key"
      command_timeout: 2m
      script:
        - echo "Executing forced command..."

---
kind: pipeline
type: docker
name: tag-release

trigger:
  event:
    - tag

steps:
  - name: reuse
    image: fsfe/reuse
  - name: lint
    image: node:20
    commands:
      - npm ci
      - npm run lint
  - name: docker-publish
    image: plugins/docker
    settings:
      registry: registry.wtf-eg.net
      repo: registry.wtf-eg.net/ki-frontend
      target: ki-frontend
      auto_tag: true
      username:
        from_secret: "docker_username"
      password:
        from_secret: "docker_password"
