name: RepoLens PR Review
on:
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
audit:
name: Audit & Comment
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run RepoLens audit (Markdown)
id: audit
uses: systm-d/repolens@main
with:
preset: 'opensource'
format: 'markdown'
fail-on: 'high'
upload-artifact: 'true'
artifact-name: 'repolens-pr-report'
- name: Read report
if: always() && steps.audit.outputs.report-path != ''
id: report
run: |
if [ -f "${{ steps.audit.outputs.report-path }}" ]; then
# Truncate report if too long for a PR comment (max ~65000 chars)
REPORT=$(head -c 60000 "${{ steps.audit.outputs.report-path }}")
{
echo "body<<REPOLENS_EOF"
echo "${REPORT}"
echo "REPOLENS_EOF"
} >> "$GITHUB_OUTPUT"
else
echo "body=No report generated." >> "$GITHUB_OUTPUT"
fi
- name: Find existing comment
if: always()
id: find-comment
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- repolens-audit-report -->'
- name: Post or update PR comment
if: always()
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
<!-- repolens-audit-report -->
## RepoLens Audit Report
| Metric | Value |
|--------|-------|
| Findings | ${{ steps.audit.outputs.findings-count }} |
| Exit Code | ${{ steps.audit.outputs.exit-code }} |
| Preset | opensource |
<details>
<summary>Full Report</summary>
${{ steps.report.outputs.body }}
</details>
---
*Generated by [RepoLens](https://github.com/systm-d/repolens) audit action*