name:  mirrors

on:
  schedule:
    - cron: "0 0 * * *"
  push:
    branches:
      - main
    paths-ignore:
      - 'updates/**'
  workflow_dispatch:

jobs:
  check:
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4

    steps:
    - uses: actions/checkout@v4
    - name: Set up Python 3.11
      uses: actions/setup-python@v5
      with:
        python-version: 3.11

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt

    - name: Run script
      run: |
        rm -rf updates/*
        python mirrors.py

    - name: Push
      uses: github-actions-x/commit@v2.9
      with:
        github-token: ${{ secrets.TOKEN }}
        push-branch: 'main'
        commit-message: 'Automatically updated using GitHub Actions'
        name: "Sonic Ma"
        email: "sonic.ma@outlook.com"
        force-add: 'true'
        force-push: 'true'
