name: Outdated Integrations
on:
  schedule:
    - cron: "0 0 * * 0" # Runs every Sunday at midnight UTC
  workflow_dispatch:

concurrency:
  # Automatically cancel previous runs if a new one is triggered to conserve resources.
  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    name: Find new major versions for the contrib package dependencies
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: write
      pull-requests: write
      id-token: write
    steps:
      # Retrieve temporary github token
      - name: Get Github token
        uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
        id: octo-sts
        with:
          policy: self.outdated-integrations
          scope: DataDog/dd-trace-go
      - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
      
      - run: go clean -modcache
      
      - name: Add dependencies
        run: |
          go get github.com/go-git/go-billy/v5/memfs
          go get github.com/go-git/go-git/v5
          go get github.com/go-git/go-git/v5/plumbing
          go get github.com/go-git/go-git/v5/storage/memory

      - run: go run .github/workflows/apps/latest_major_versions.go
        env:
          GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
