Skip to content

[ci] Fix docs validation notification: use Jobs API instead of artifacts - #18053

Merged
theletterf merged 1 commit into
mainfrom
ci/inline-docs-validation-notify
Mar 26, 2026
Merged

theletterf merged 1 commit into
mainfrom
ci/inline-docs-validation-notify

Conversation

@theletterf

@theletterf theletterf commented Mar 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Reworks the notification mechanism for the package docs validation workflow. When docs-builder finds errors, a comment is posted on the PR mentioning @elastic/integration-docs.

How it works

  1. Validation workflow (validate-package-docs.yml): When docs-builder exits non-zero, uploads a docs-validation-failed artifact containing the PR number. Uses upload-artifact@v7. Stays non-blocking (continue-on-error: true) with contents: read only.

  2. Notification workflow (notify-package-docs-failure.yml): Triggered by workflow_run. Downloads the artifact via download-artifact@v8 with run-id and github-token for cross-workflow access. If artifact exists, posts a comment. Permissions at job level (pull-requests: write, actions: read).

Security

  • Validation workflow: pull_request trigger, contents: read only — safe for forks
  • Notification workflow: workflow_run trigger, runs in base branch context — safe for forks
  • Permissions at job level per least-permissive approach
  • All GitHub context values passed via env vars, not inline interpolation

Testing

Artifact upload confirmed in test PR #18049.

🤖 Generated with Claude Code

@theletterf
theletterf requested a review from a team as a code owner March 25, 2026 16:52

permissions:
contents: read
pull-requests: write

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v1v is there any inconvenient on setting this permission in Github workflows?

I see there are other workflows setting that permission, but I'd like to double check it for this workflow.

This would be needed to post comment in Pull Requests (keep me honest here @theletterf )

@theletterf theletterf Mar 25, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worst thing that might happen from a fork is someone writing a different comment on their own PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We follow the least-permissive approach, so permissions are at the job level rather than at the top-level. That's my suggestion here.

OTOH, this won't work for forked PRs, this GitHub workflow runs for PRs in an unprivileged environment. Maybe it will be interesting to provide a workaround for those forked PRs with a job summary:

Or, we could support the pull-request/workflow_run approach:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check — might split it again.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworked — dropped pull-requests: write from the validation workflow entirely. Now using the two-workflow split: the notification workflow downloads the validation run's logs via the API and greps for docs-builder's error/warning summary line. Permissions are at job level.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v1v Thanks for the feedback — reworked the approach:

  • Validation workflow stays read-only (contents: read only), keeps continue-on-error: true, no pull-requests: write
  • Notification workflow (workflow_run trigger) downloads the validation run's logs via the API and greps for docs-builder's summary line (N Errors / N Warnings). This works regardless of continue-on-error masking step conclusions
  • Permissions are at job level per least-permissive approach
  • Works for fork PRs since the workflow_run trigger runs in the base branch context

Could you take another look?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't add any GitHub comments with the outcome. If you are looking for that feature, you could use the upload-artefact/download-artifact steps between the two different workflows.

I recall I saw something like that in the past

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v1v Reworked per your suggestions:

  • Validation workflow stays read-only (contents: read only), no pull-requests: write. Uses upload-artifact@v7 to upload a signal file with the PR number when docs-builder finds errors
  • Notification workflow uses download-artifact@v8 with run-id and github-token to download the artifact cross-workflow. Permissions at job level (pull-requests: write, actions: read)
  • Artifact upload confirmed working in test PR [test] Intentional doc errors to test validation + notification #18049

Could you take another look?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v1v Updated again based on further review:

  • Validation workflow: contents: read only, no write permissions. Uses upload-artifact@v7 to upload a signal file when docs-builder finds errors. PR_NUMBER passed as env var (no inline ${{ }} in shell)
  • Notification workflow: download-artifact@v8 with run-id + github-token for cross-workflow download. Permissions at job level (pull-requests: write, actions: read)
  • Fork safety: The notification workflow verifies the PR number from the artifact matches the actual PR for the head SHA (GET /repos/{repo}/commits/{sha}/pulls), preventing a forked PR from targeting a different PR's comments
  • Fork support: Works for fork PRs — artifacts are stored in the upstream repo, and download-artifact@v8 can access them from the workflow_run context

Artifact upload confirmed in test PR #18049.

@theletterf
theletterf force-pushed the ci/inline-docs-validation-notify branch 2 times, most recently from aadab2b to 30705d2 Compare March 25, 2026 17:59
@theletterf theletterf changed the title [ci] Inline docs validation notification, remove separate workflow [ci] Fix docs validation notification: use Jobs API instead of artifacts Mar 25, 2026
@theletterf
theletterf force-pushed the ci/inline-docs-validation-notify branch from 30705d2 to f891c3c Compare March 25, 2026 19:00
Comment thread .github/workflows/validate-package-docs.yml Outdated
…rkflow

Use upload-artifact@v7 / download-artifact@v8 for cross-workflow
signaling. Validation workflow uploads a "docs-validation-failed"
artifact with the PR number when docs-builder finds errors.
Notification workflow downloads it and posts a comment.

- Validation workflow: contents: read only, continue-on-error: true
- Notification workflow: permissions at job level (pull-requests: write,
  actions: read), runs via workflow_run in base branch context
- Artifact confirmed uploaded in test PR #18049

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@theletterf
theletterf force-pushed the ci/inline-docs-validation-notify branch from f891c3c to 88d7cc1 Compare March 25, 2026 19:03

@v1v v1v left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +13 to +15
permissions:
pull-requests: write
actions: read

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤟

name: docs-validation-failed
path: validate-result/pr_number
if-no-files-found: ignore
retention-days: 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@theletterf
theletterf requested review from mrodm and v1v March 26, 2026 08:33

@mrodm mrodm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@theletterf
theletterf merged commit 17d152f into main Mar 26, 2026
12 checks passed
@theletterf
theletterf deleted the ci/inline-docs-validation-notify branch March 26, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants