name: facades

on:
  push:
    branches:
      - master
      - '*.x'
  workflow_dispatch:

jobs:
  update:
    runs-on: ubuntu-22.04

    strategy:
      fail-fast: true

    name: Facade DocBlocks

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          extensions: :php-psr
          php-version: 8.1
          tools: composer:v2
          coverage: none

      - name: Set Framework version
        run: composer config version "10.x-dev"

      - name: Install dependencies
        uses: nick-fields/retry@v3
        with:
          timeout_minutes: 5
          max_attempts: 5
          command: |
            composer config repositories.facade-documenter vcs git@github.com:laravel/facade-documenter.git
            composer require --dev laravel/facade-documenter:dev-main --prefer-stable --prefer-dist --no-interaction --no-progress

      - name: Update facade docblocks
        run: |
          php -f vendor/bin/facade.php -- \
            Illuminate\\Support\\Facades\\App \
            Illuminate\\Support\\Facades\\Artisan \
            Illuminate\\Support\\Facades\\Auth \
            Illuminate\\Support\\Facades\\Blade \
            Illuminate\\Support\\Facades\\Broadcast \
            Illuminate\\Support\\Facades\\Bus \
            Illuminate\\Support\\Facades\\Cache \
            Illuminate\\Support\\Facades\\Config \
            Illuminate\\Support\\Facades\\Cookie \
            Illuminate\\Support\\Facades\\Crypt \
            Illuminate\\Support\\Facades\\DB \
            Illuminate\\Support\\Facades\\Date \
            Illuminate\\Support\\Facades\\Event \
            Illuminate\\Support\\Facades\\File \
            Illuminate\\Support\\Facades\\Gate \
            Illuminate\\Support\\Facades\\Hash \
            Illuminate\\Support\\Facades\\Http \
            Illuminate\\Support\\Facades\\Lang \
            Illuminate\\Support\\Facades\\Log \
            Illuminate\\Support\\Facades\\Mail \
            Illuminate\\Support\\Facades\\Notification \
            Illuminate\\Support\\Facades\\ParallelTesting \
            Illuminate\\Support\\Facades\\Password \
            Illuminate\\Support\\Facades\\Pipeline \
            Illuminate\\Support\\Facades\\Process \
            Illuminate\\Support\\Facades\\Queue \
            Illuminate\\Support\\Facades\\RateLimiter \
            Illuminate\\Support\\Facades\\Redirect \
            Illuminate\\Support\\Facades\\Redis \
            Illuminate\\Support\\Facades\\Request \
            Illuminate\\Support\\Facades\\Response \
            Illuminate\\Support\\Facades\\Route \
            Illuminate\\Support\\Facades\\Schema \
            Illuminate\\Support\\Facades\\Session \
            Illuminate\\Support\\Facades\\Storage \
            Illuminate\\Support\\Facades\\URL \
            Illuminate\\Support\\Facades\\Validator \
            Illuminate\\Support\\Facades\\View \
            Illuminate\\Support\\Facades\\Vite

      - name: Commit facade docblocks
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: Update facade docblocks
          file_pattern: src/
