name: Trunk Cache

permissions: read-all

on:
  workflow_call:
  workflow_dispatch:
  push:
    branches:
      - main
    paths:
      - .trunk/trunk.yaml
  schedule:
    - cron: "0 9 * * 1" # 9am Tooling Monday

concurrency:
  group: ${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  trunk-cache:
    name: Trunk Cache
    runs-on: ubuntu-latest
    permissions:
      actions: write
    steps:
      - name: "Setup PHP"
        uses: shivammathur/setup-php@v2
        with:
          php-version: 8.3
      - name: "Checkout"
        uses: actions/checkout@v4
      - name: "Trunk Cache"
        uses: trunk-io/trunk-action@v1
        with:
          check-mode: populate_cache_only