Description Quality Check #1269
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Description Quality Check | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - '_posts/**' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - '_posts/**' | |
| workflow_run: | |
| workflows: ["Collect Crypto News", "Collect Stock News"] | |
| types: [completed] | |
| workflow_dispatch: | |
| inputs: | |
| days: | |
| description: 'Number of days to check' | |
| default: '7' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| concurrency: | |
| group: description-quality-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| quality-check: | |
| # workflow_run 트리거 시 upstream 수집기 잡이 success 인 경우에만 실행. | |
| # 이전: collector 실패 후에도 stale _posts 에 대해 quality 검사가 돌아 | |
| # 가짜 결과(빈 _posts 기반)를 산출 → silent fail. push / pull_request / | |
| # workflow_dispatch 트리거는 게이트 우회. | |
| if: >- | |
| github.event_name != 'workflow_run' || | |
| github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Setup Python | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| cache-dependency-path: scripts/requirements.txt | |
| - name: Install dependencies | |
| run: pip install -r scripts/requirements.txt | |
| - name: Check description quality | |
| env: | |
| PYTHONPATH: scripts | |
| run: | | |
| python scripts/check_description_quality.py \ | |
| --days ${{ inputs.days || '7' }} \ | |
| --warn-threshold 50 \ | |
| --format text | |
| - name: Generate markdown report | |
| if: always() | |
| env: | |
| PYTHONPATH: scripts | |
| run: | | |
| python scripts/check_description_quality.py \ | |
| --days ${{ inputs.days || '7' }} \ | |
| --warn-threshold 50 \ | |
| --format markdown > /tmp/description-quality-report.md | |
| cat /tmp/description-quality-report.md >> "$GITHUB_STEP_SUMMARY" | |
| - name: Post PR comment | |
| if: always() && github.event_name == 'pull_request' | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const marker = '<!-- description-quality-bot -->'; | |
| const reportPath = '/tmp/description-quality-report.md'; | |
| const reportContent = fs.existsSync(reportPath) | |
| ? fs.readFileSync(reportPath, 'utf8') | |
| : '## Description Quality Report\n\nNo report generated.'; | |
| const body = `${marker}\n${reportContent}`; | |
| const issue_number = context.payload.pull_request.number; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number, | |
| per_page: 100, | |
| }); | |
| const existing = comments.find( | |
| (comment) => | |
| comment.user.type === 'Bot' && | |
| typeof comment.body === 'string' && | |
| comment.body.includes(marker) | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number, | |
| body, | |
| }); | |
| } |