name: Generate and push repros to the next branch

on:
  schedule:
    - cron: '2 2 */1 * *'
  workflow_dispatch:
  # To remove when the branch will be merged
  push:
    branches:
      - vite-frameworks-xyz

jobs:
  generate:
    runs-on: ubuntu-latest
    env:
      YARN_ENABLE_IMMUTABLE_INSTALLS: false
    steps:
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - uses: actions/checkout@v3
      - name: Setup git user
        run: |
          git config --global user.name "Storybook Bot"
          git config --global user.email "bot@storybook.js.org"
      - name: Install dependencies
        run: node ./scripts/check-dependencies.js
      - name: Compile Storybook libraries
        run: yarn task --task publish --start-from=auto --no-link
      - name: Generate repros
        run: yarn generate-repros-next --local-registry
        working-directory: ./code
      - name: Publish repros to GitHub
        run: yarn publish-repros --remote=https://storybook-bot:${{ secrets.PAT_STORYBOOK_BOT}}@github.com/storybookjs/repro-templates-temp.git --push
        working-directory: ./code
