name: Update markdown snippets
on:
  push:
jobs:
  update-markdown-snippets:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run MarkdownSnippets
        run: |
          dotnet tool install --global MarkdownSnippets.Tool
          mdsnippets ${GITHUB_WORKSPACE}
        shell: bash
      - name: Prettier
        run: ./format_code.sh
        shell: bash
      - name: Push changes
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git commit -m ". d updated markdown snippets & formatting" -a  || echo "nothing to commit"
          remote="https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git"
          branch="${GITHUB_REF:11}"
          git push "${remote}" ${branch} || echo "nothing to push"
        shell: bash
