---
name: "Bump Trivy version"
scms:
  image-scanning:
    kind: "github"
    spec:
      user: "{{ .github.user }}"
      email: "{{ .github.email }}"
      username: "{{ .github.username }}"
      token: "{{ requiredEnv .github.token }}"
      owner: "rancher"
      repository: "image-scanning"
      branch: "main"
      commitmessage:
        title: "Bump Trivy version"

actions:
  github:
    title: "Bump Trivy version"
    kind: "github/pullrequest"
    scmid: "image-scanning"
    spec:
      automerge: false
      mergemethod: "squash"
      usetitleforautomerge: true

sources:
  trivy-release:
    name: "Get Trivy latest release"
    kind: "githubrelease"
    spec:
      owner: "aquasecurity"
      repository: "trivy"
      token: "{{ requiredEnv .github.token }}"
      versionfilter:
        kind: "latest"

conditions:
  trivy-version:
    name: "Check Trivy usage in image-scanning"
    kind: "file"
    scmid: "image-scanning"
    disablesourceinput: true
    spec:
      file: ".github/workflows/scan.yml"
      matchpattern: 'TRIVY_VERSION: "v\d+\.\d+.\d+"'

targets:
  trivy-version:
    name: "Update Trivy version in image-scanning"
    kind: "file"
    scmid: "image-scanning"
    disablesourceinput: true
    spec:
      file: ".github/workflows/scan.yml"
      matchpattern: 'TRIVY_VERSION: "v\d+\.\d+.\d+"'
      replacepattern: 'TRIVY_VERSION: "{{ source `trivy-release` }}"'
