name: Comment on PR (Generated VRL Docs) on: workflow_run: workflows: ["Check Generated VRL Docs Freshness"] types: - completed permissions: contents: read jobs: comment: runs-on: ubuntu-latest if: > github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' permissions: pull-requests: write steps: - name: Download PR metadata uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: name: vrl-docs-check-pr run-id: ${{ github.event.workflow_run.id }} github-token: ${{ github.token }} - name: Comment on PR uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: | const fs = require('fs'); const prNumber = parseInt(fs.readFileSync('pr-number', 'utf8').trim(), 10); if (isNaN(prNumber)) { core.setFailed('Invalid PR number'); return; } const marker = ''; const body = marker + '\nThe `docs/generated/` folder is out of date but I was unable to push the fix automatically.\n\nPlease run the following and commit the result:\n\n```\nmake generate-vector-vrl-docs\n```'; const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, }); const existing = comments.find(c => c.body.startsWith(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: prNumber, body, }); }