when:
  - event: [cron]
    cron: govulncheck
  - event: [pull_request]
  - event: push
    branch:
      - ${CI_REPO_DEFAULT_BRANCH}

variables:
  - &go_image 'golang:1.22'

steps:
  govulncheck:
    image: *go_image
    pull: true
    commands:
      - make generate
      - go install golang.org/x/vuln/cmd/govulncheck@latest
      - govulncheck ./...

  email:
    image: deblan/woodpecker-email
    settings:
      dsn:
        from_secret: email_dsn
      from:
        address:
          from_secret: email_from_address
        name: Woodpecker
      recipients:
        - notifications@twhelp.app
      recipients_only: true
      content:
        subject:
          "[govulncheck - {{ pipeline.status }}] {{ repo.full_name }} ({{ commit.branch }} - {{ commit.sha[0:8] }}"
    when:
      status: [success, failure]
      event: cron
