---
name: Generate Updates PR
on:
  schedule:
    - cron: '0 0 * * *'  # Daily
  workflow_dispatch:
env:
  GH_TOKEN: ${{ secrets.CREW_PR_TOKEN }}  # setting GH_TOKEN for the entire workflow
permissions:                    # Global permissions configuration starts here
  actions: write
  contents: write
  packages: write
  pull-requests: write          # 'write' access to pull requests
jobs:
  pip-update-checks:
    if: ${{ github.repository_owner == 'chromebrew' }}
    uses: ./.github/workflows/Updater-on-Demand.yml
    secrets: inherit
    with:
      version_cmd_input: "py3_*"
  gem-update-checks:
    if: ${{ github.repository_owner == 'chromebrew' }}
    uses: ./.github/workflows/Updater-on-Demand.yml
    secrets: inherit
    with:
      version_cmd_input: "ruby_*"
  core-buildessential-update-checks:
    if: ${{ github.repository_owner == 'chromebrew' }}
    uses: ./.github/workflows/Package-Dependencies-Updater.yml
    secrets: inherit
    with:
      version_cmd_input: "core buildessential"
  generic-packages:
    runs-on: ubuntu-24.04
    outputs:
      packages: ${{ steps.get-packages.outputs.packages }}
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0
      - name: Get generic automatically updatable packages
        id: get-packages
        run: echo "packages=$(cat tools/automatically_updatable_packages.txt | xargs)" >> "$GITHUB_OUTPUT"
  generic-packages-update-checks:
    needs: generic-packages
    if: ${{ github.repository_owner == 'chromebrew' }}
    uses: ./.github/workflows/Updater-on-Demand.yml
    secrets: inherit
    with:
      version_cmd_input: ${{ needs.generic-packages.outputs.packages }}
