# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "Render Readme"

on:
  workflow_call:
    secrets:
      BOT_APP_ID:
        description: The App ID of the GitHub App
        required: true
      BOT_APP_PRIVATE_KEY:
        description: The private key of the GitHub App
        required: true

jobs:
  render-readme:
    name: Render README
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        token: "${{ secrets.GITHUB_TOKEN }}"

    - name: Install Python Requirements
      shell: bash
      run: pip install -r ./.forgejo/scripts/requirements.txt && pip freeze

    - name: Install Goss
      shell: bash
      run: |
        curl -fsSL https://goss.rocks/install | sh

    - name: Run Compliance Tests and Render README
      env:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
      shell: bash
      run: python ./.forgejo/scripts/render-readme.py

    - name: Commit Changes
      shell: bash
      env:
        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
      run: |
        git config --global user.name "forgejo-workflow"
        git config --global user.email "tommy+forgejo@252.no"
        git add ./README.org
        git commit -m "chore: render README.org" || echo "No changes to commit"
        #git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@code.252.no/tommy/containers.git || echo "No changes to push"
