name: 重建歌词文件夹
on:
  workflow_dispatch:
  push:
    branches: [ main ]
    paths: 
      - 'scripts/**'
      - 'raw-lyrics/**'
concurrency:
  group: check-submit
  cancel-in-progress: true

jobs:
  check-submit:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - name: 签出代码
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: 安装稳定版本的 Rust 工具链
        run: rustup toolchain install stable --profile minimal
      - name: 准备 Rust 缓存
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: scripts/rebuild-folder -> target
      - name: 运行重建程序
        timeout-minutes: 10
        run: |
          git config --global user.name 'github-actions'
          git config --global user.email 'github-actions@users.noreply.github.com'
          cargo run --release --locked
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        working-directory: scripts/rebuild-folder
