text: name: SE
  on:
    schedule:
      - cron: 0 0 */3 * *
  jobs:
    qa:
      name: Syntax Enforcer
      runs-on: ubuntu-latest
      if: github.repository_owner == 'PreMiD'
      steps:
        - name: Checkout Project
          uses: actions/checkout@v2
        - name: Use Node.js 12
          uses: actions/setup-node@v1
          with:
            node-version: 12
        - name: Restore CI Cache
          uses: actions/cache@v1
          with:
            path: node_modules
            key: ${{ runner.os }}-12-${{ hashFiles('**/yarn.lock') }}
        - name: Install Deps
          run: yarn
        - name: Compile Script
          run: yarn se:compile
        - name: Start SE
          run: |
            git config --global core.quotePath false
            git config --global core.precomposeunicode true
            yarn se
        - name: Commit any changes
          if: always()
          run: |
            git add .;
            if git diff-index --quiet HEAD --; then
              exit 0;
            else
              hub config --global hub.protocol https;
              hub config --global user.email "${GITHUB_EMAIL}";
              hub config --global user.name "${GITHUB_USER}";
              hub remote set-url origin "https://${GITHUB_TOKEN}:x-oauth-basic@github.com/${GITHUB_REPOSITORY}.git";
              git config --local user.email "${GITHUB_EMAIL}";
              git config --local user.name "${GITHUB_USER}";
              git checkout -b semid/qa/`date +%F-%H-%M`;
              git commit -sam "♻️ Refactoring";
              hub pull-request -p -m "🤖 Semi-weekly SE" -m "*beep boop* I've prettified and refactored some Presences...";
            fi
          env:
            GITHUB_USER: SeMiD
            GITHUB_EMAIL: contact@premid.app
            GITHUB_TOKEN: ${{ secrets.AUTOMERGE }}
  