test-vale-report #36
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: test-vale-report | |
| on: | |
| workflow_run: | |
| workflows: ["test-vale-lint"] | |
| types: [completed] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| actions: read | |
| jobs: | |
| test-report: | |
| name: Test report action | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event.workflow_run.event == 'pull_request' && | |
| github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Run report action | |
| uses: ./vale/report | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Verify comment was posted | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_REPO: ${{ github.repository }} | |
| HEAD_SHA: ${{ github.event.workflow_run.head_sha }} | |
| run: | # zizmor: ignore[template-injection] workflow_run payload in test harness | |
| PR_NUMBER=$(echo '${{ toJSON(github.event.workflow_run.pull_requests) }}' | jq -r '.[0].number') | |
| if [ "$PR_NUMBER" == "null" ] || [ -z "$PR_NUMBER" ]; then | |
| echo "Could not determine PR number, searching by head SHA..." | |
| PR_NUMBER=$(gh pr list --repo "$GH_REPO" --state open --json number,headRefOid \ | |
| --jq ".[] | select(.headRefOid == \"${HEAD_SHA}\") | .number" | head -1) | |
| fi | |
| if [ -z "$PR_NUMBER" ]; then | |
| echo "::warning::Could not find PR number to verify comment" | |
| exit 0 | |
| fi | |
| echo "Checking for Vale comment on PR #${PR_NUMBER}..." | |
| COMMENT_EXISTS=$(gh api "repos/${GH_REPO}/issues/${PR_NUMBER}/comments" \ | |
| --jq '.[] | select(.body | contains("Elastic Docs Style Checker (Vale)")) | .id' | head -1) | |
| if [ -n "$COMMENT_EXISTS" ]; then | |
| echo "Vale linting results comment found (comment ID: $COMMENT_EXISTS)" | |
| else | |
| echo "::error::Vale linting results comment not found on PR #${PR_NUMBER}" | |
| exit 1 | |
| fi |