Repository navigation
Add API docs preview workflow for pull requests - #21645
Open
NullVoxPopuli-ai-agent wants to merge 1 commit into
Open
NullVoxPopuli-ai-agent wants to merge 1 commit into
NullVoxPopuli-ai-agent wants to merge 1 commit into
Conversation
A pull request with the `api-docs-preview` label gets a build of the ember-api-docs app with the docs of that pull request. The build is an artifact, and a comment on the pull request gives the link and the commands to view it. Two workflows do the work. The build runs the code of the pull request, so it runs on `pull_request` with a read-only token. The comment needs write access, so it runs on `workflow_run` and runs no code from the pull request. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the
api-docs-previewlabel to a PR. About 2 minutes later, a comment on the PR gives a link to the API docs site for that PR and the commands to view it.Example comment, from a test PR in my fork: NullVoxPopuli-ai-agent#16 (comment)
Before the first use
api-docs-previewlabel. This repository does not have it.main, so no comment can show on this PR itself.What the preview is
The artifact is a build of ember-api-docs, the app of https://api.emberjs.com, with the docs of the PR. The data comes from the same steps as
docs.yml:pnpm run docs, thenember-jsonapi-docs, thenfix:files. The zip file is about 5 MB.To view it, a reader runs two commands from the comment:
A new commit on a labeled PR starts a new build, and the same comment gets the new link.
Why there are two workflow files
The build installs and runs code from the PR, and the comment needs write access. One job with both is the "pwn request" problem.
api-docs-preview.ymlpull_requestapi-docs-preview-comment.ymlworkflow_runpull-requests: writeA PR from a fork gets a read-only token on
pull_request, so the build workflow cannot post the comment.The comment workflow reads no file from the artifact. It finds the PR from the head repository, branch, and SHA that GitHub supplies. A PR cannot change those values, so it cannot make the bot comment on a different PR.
Limits
Tests
I ran both workflows in my fork, on a test PR:
api-docs-previewlabel: the build passed in 1.5 minutes, and the comment showed.actionlintandzizmor1.30.1 report no findings for the two files.Not tested in a run: a PR from a different repository. For that case, I ran the PR lookup query against this repository with the values of #21630, and it returned 21630.
🤖 Generated with Claude Code