name: Commit changes on @pob/root update

on:
  push:
    branches:
      - "renovate/pob-root"
      - "renovate/pob-root-**"
      - "renovate/major-pob-root"

permissions:
  contents: write

jobs:
  run-install-and-commit-modified-files:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          ssh-key: ${{ secrets.PUSH_DEPLOY_KEY }}

      - $ciPreStep$

      - uses: actions/setup-node@v6
        with:
          node-version: 24

      - name: Install Dependencies
        # no immutable here
        run: $installMutableCommand$
        env:
          YARN_ENABLE_IMMUTABLE_INSTALLS: false

      - name: Run pob-root-postinstall
        run: $pmExec$ pob-root-postinstall

      - name: Run pob update
        run: npx pob update --force
        env:
          YARN_ENABLE_IMMUTABLE_INSTALLS: false

      - name: Check for added or modified files
        id: git-check-modified
        run: if [[ -z $(git status -s) ]]; then echo "modified=false" >> $GITHUB_OUTPUT ; else echo "modified=true" >> $GITHUB_OUTPUT ; fi

      - name: Commit report
        if: steps.git-check-modified.outputs.modified == 'true'
        run: |
          git add .
          git -c user.name="Christophe Hurpeau" \
            -c user.email="christophehurpeau@users.noreply.github.com" \
            commit -m "chore: update pob root" --author="github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
          git push --no-verify
        env:
          YARN_ENABLE_IMMUTABLE_INSTALLS: false
