name: cron
on:
  workflow_dispatch:
    inputs:
      prefix:
        description: 'Prefix to regenerate'
        required: true
        default: 'master'
  schedule:
    - cron: "10 10 */2 * *"
jobs:
  gen:
    runs-on: ubuntu-latest
    env:
      DEFAULT_PREFIX: master
    steps:
      - name: make some space
        run: "sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/share/boost $AGENT_TOOLSDIRECTORY"
    
      - name: checkout
        uses: actions/checkout@v2

      # Override PREFIX if run manually
      - name: Set PREFIX
        run: echo "PREFIX=${{ github.event.inputs.prefix || env.DEFAULT_PREFIX }}" >> $GITHUB_ENV

      - name: delete folders to regenerate
        run: "rm -rf ${{ env.PREFIX }}*"

      - name: generate
        run: make gen

      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Adding new schemas
          commit_user_name: Yann Hamon
          commit_user_email: yann+github@mandragor.org
          commit_author: Yann Hamon <yann+github@mandragor.org>
