name: Export after tests

permissions:
  contents: write

on:
  workflow_run:
    workflows: ["Test"]
    types:
      - completed
    branches: [ master ]
  workflow_dispatch:

jobs:
  run-export:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        fetch-depth: 0

    - name: Set up PHP
      uses: shivammathur/setup-php@v2
      with:
        php-version: '8.1'
        extensions: mbstring

    - name: Run export script
      run: php export.php

    - name: Commit changes
      uses: stefanzweifel/git-auto-commit-action@v4
      with:
        commit_message: "Run export.php — update exported data [skip ci]"
