Trez.One 0f936a6047
Renovate / renovate (push) Has been cancelled
...
2025-10-23 14:23:49 -04:00
2025-10-19 10:18:28 -04:00
...
2025-10-23 14:23:49 -04:00
...
2025-10-23 14:23:49 -04:00
2025-10-19 10:18:28 -04:00
...
2025-10-23 14:23:49 -04:00
2025-10-19 10:18:28 -04:00
2025-10-22 17:28:40 -04:00

🧱 Git Auto Comment Action

Automatically post comments or pull request reviews to Gitea or GitHub, with optional debug logging and diff parsing.


🚀 Features

  • 🧩 Supports GitHub and Gitea
  • 💬 Posts formatted PR comments or reviews
  • 🪶 Uses {line} / {lines} placeholders in templates
  • 🧠 Parses diffs to include relevant code changes
  • 🎨 Optional colorized debug mode

🧰 Inputs

Name Required Default Description
platform No github Target platform (github or gitea)
token API token
repo_owner Repository owner
repo_name Repository name
pr_index Pull request index (Gitea) or issue number (GitHub)
api_url No Base API URL (required for Gitea)
diff No Diff or plan text to include in the comment
comment_template No "Auto-comment: changed line -> {line}" Template text. Supports {line} and {lines} placeholders
debug No false Enable verbose, colorized debug logs

🧮 Example Usage

name: Auto PR Comment

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  comment:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Post PR Comment
        uses: your-org/git-auto-comment@main
        with:
          platform: gitea
          token: ${{ secrets.GITEA_TOKEN }}
          repo_owner: "tar-valon"
          repo_name: "terraform-configs"
          pr_index: ${{ github.event.pull_request.number }}
          api_url: "https://gitea.example.com/api/v1"
          diff: |
            + added line one
            + added line two
          comment_template: |
            🧱 **Terraform Plan Output**
            ```
            {lines}
            ```
          debug: "true"

🧩 Debug Mode

Set debug: "true" (or environment variable DEBUG=true) to enable verbose, colorized output:

  • Prints API endpoint, payload size, and preview
  • Truncates long payloads automatically
  • Highlights errors and successes in color

🧪 Local Testing

export PLATFORM=gitea
export TOKEN=your_token
export REPO_OWNER=myorg
export REPO_NAME=myrepo
export PR_INDEX=42
export API_URL=https://gitea.example.com/api/v1
export COMMENT_TEMPLATE="Plan output:\n{lines}"
export DIFF="$(git diff HEAD~1)"
export DEBUG=true

python git-auto-comment.py
S
Description
No description provided
Readme MIT 56 KiB
Languages
Python 100%