1
0
mirror of synced 2025-12-19 09:57:42 -05:00
Files
docs/.github/workflows/readability.yml
dependabot[bot] 3e333183fb Bump actions/checkout from 5.0.0 to 6.0.1 (#58937)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-16 23:37:47 +00:00

109 lines
3.9 KiB
YAML

name: Readability report
# **What it does**: Analyzes readability of rendered content for changed Markdown files in pull requests
# **Why we have it**: We want to track and improve the readability of our documentation over time
# **Who does it impact**: Contributors and content writers
on:
# pull_request:
# paths:
# - 'content/**/*.md'
# - 'data/reusables/**/*.md'
# The pull_request trigger is currently disabled for testing purposes.
# Re-enable this trigger when ready to run readability analysis automatically on PRs.
workflow_dispatch:
inputs:
pull_request_number:
description: 'Pull request number to analyze (for testing)'
required: true
type: number
permissions:
contents: read
pull-requests: write
jobs:
readability-analysis:
if: github.repository == 'github/docs-internal'
runs-on: ubuntu-latest
steps:
- name: Check out repo with full history
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Checkout PR for manual dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
gh pr checkout ${{ inputs.pull_request_number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/node-npm-setup
- uses: ./.github/actions/get-docs-early-access
if: ${{ github.repository == 'github/docs-internal' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
- name: Get changed content files
id: changed_files
uses: ./.github/actions/get-changed-files
with:
files: 'content/**/*.md'
# For workflow_dispatch, compare against main
base: ${{ github.event_name == 'workflow_dispatch' && 'main' || '' }}
- name: Disable Next.js telemetry
run: npx next telemetry disable
- name: Start server in the background
if: ${{ steps.changed_files.outputs.filtered_changed_files }}
run: npm start > /tmp/stdout.log 2> /tmp/stderr.log &
- name: Run readability analysis
if: ${{ steps.changed_files.outputs.filtered_changed_files }}
env:
CHANGED_FILES: ${{ steps.changed_files.outputs.filtered_changed_files }}
run: npm run readability-report
- name: Find existing readability comment
if: ${{ steps.changed_files.outputs.filtered_changed_files }}
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad
id: findComment
with:
issue-number: ${{ github.event_name == 'workflow_dispatch' && inputs.pull_request_number || github.event.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- READABILITY_REPORT -->'
- name: Read readability report
if: ${{ steps.changed_files.outputs.filtered_changed_files }}
id: read_report
run: |
if [ -f "readability-report.md" ]; then
{
echo 'report<<EOF'
cat readability-report.md
echo EOF
} >> "$GITHUB_OUTPUT"
fi
- name: Create or update readability comment
if: ${{ steps.changed_files.outputs.filtered_changed_files && steps.read_report.outputs.report }}
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9
with:
comment-id: ${{ steps.findComment.outputs.comment-id }}
issue-number: ${{ github.event_name == 'workflow_dispatch' && inputs.pull_request_number || github.event.number }}
body: |
<!-- READABILITY_REPORT -->
${{ steps.read_report.outputs.report }}
edit-mode: replace
- if: ${{ failure() }}
name: Debug server outputs on errors
run: |
echo "____STDOUT____"
cat /tmp/stdout.log || echo "No stdout log found"
echo "____STDERR____"
cat /tmp/stderr.log || echo "No stderr log found"