name: Sharg Markdown

on:
  push:
    branches:
      - 'main'

env:
  TZ: Europe/Berlin

defaults:
  run:
    shell: bash -exo pipefail {0}

jobs:
  readme-snippet:
    name: Update README
    concurrency:
      group: readme-snippet-${{ github.ref }}
      cancel-in-progress: true
    runs-on: ubuntu-22.04
    timeout-minutes: 15
    steps:
      - name: Checkout Sharg
        uses: actions/checkout@v3
        with:
          token: ${{ secrets.SEQAN_ACTIONS_PAT }}

      - name: Import GPG key
        uses: crazy-max/ghaction-import-gpg@v4
        with:
          gpg_private_key: ${{ secrets.SEQAN_ACTIONS_GPG_KEY }}
          passphrase: ${{ secrets.SEQAN_ACTIONS_GPG_PASSPHRASE }}
          git_user_signingkey: true
          git_commit_gpgsign: true

      - name: Update README
        uses: dineshsonachalam/markdown-autodocs@v1.0.7
        with:
          commit_author: seqan-actions[bot]
          commit_user_email: seqan-actions@users.noreply.github.com
          commit_message: "[MISC] Update README.md"
          output_file_paths: '[./README.md]'
          categories: '[code-block]'
