steps:
  test:
    image: golang:1.25-alpine
    commands:
      - go test ./...
    when:
      - event: [push, pull_request]

  build:
    image: golang:1.25-alpine
    commands:
      - go build -o app ./cmd/api
    when:
      - event: [push, pull_request]

  docker:
    image: woodpeckerci/plugin-kaniko
    settings:
      registry: registry.threesix.ai
      repo: "{{PROJECT_NAME}}"
      tags:
        - latest
        - ${CI_COMMIT_SHA:0:8}
      cache: true
      skip-tls-verify: true
    when:
      - event: push
        branch: main

  deploy:
    image: bitnami/kubectl:latest
    commands:
      - kubectl set image deployment/{{PROJECT_NAME}} {{PROJECT_NAME}}=registry.threesix.ai/{{PROJECT_NAME}}:${CI_COMMIT_SHA:0:8} -n projects
    when:
      - event: push
        branch: main
