-
Notifications
You must be signed in to change notification settings - Fork 433
Add developer guide documentation build workflow #3997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shai-almog
merged 4 commits into
master
from
codex/add-github-actions-workflow-for-developer-guide
Oct 20, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e026ab7
Add workflow to build developer guide documentation
shai-almog d759ba2
Harden developer guide workflow for forks
shai-almog 83db0a5
Exclude sketch assets from developer guide HTML package
shai-almog bc1b71e
Exclude docs directory from PR CI push triggers
shai-almog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| name: Build Developer Guide Docs | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'docs/developer-guide/**' | ||
| - '.github/workflows/developer-guide-docs.yml' | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
| actions: read | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.1' | ||
|
|
||
| - name: Install Asciidoctor tooling | ||
| run: | | ||
| gem install --no-document asciidoctor asciidoctor-pdf | ||
|
|
||
| - name: Build Developer Guide HTML and PDF | ||
| run: | | ||
| set -euo pipefail | ||
| OUTPUT_ROOT="build/developer-guide" | ||
| HTML_BUILD_DIR="${OUTPUT_ROOT}/html" | ||
| PDF_BUILD_DIR="${OUTPUT_ROOT}/pdf" | ||
| PACKAGE_DIR="${OUTPUT_ROOT}/html-package" | ||
| mkdir -p "$HTML_BUILD_DIR" "$PDF_BUILD_DIR" | ||
| asciidoctor -D "$HTML_BUILD_DIR" -o developer-guide.html docs/developer-guide/developer-guide.asciidoc | ||
| asciidoctor-pdf -D "$PDF_BUILD_DIR" -o developer-guide.pdf docs/developer-guide/developer-guide.asciidoc | ||
| rm -rf "$PACKAGE_DIR" | ||
| mkdir -p "$PACKAGE_DIR" | ||
| cp "$HTML_BUILD_DIR/developer-guide.html" "$PACKAGE_DIR/" | ||
| for asset_dir in docs/developer-guide/*; do | ||
| base_name="$(basename "$asset_dir")" | ||
| if [ -d "$asset_dir" ] && [ "$base_name" != "sketch" ]; then | ||
| cp -R "$asset_dir" "$PACKAGE_DIR/" | ||
| fi | ||
| done | ||
| (cd "$PACKAGE_DIR" && zip -r "../developer-guide-html.zip" .) | ||
|
|
||
| - name: Upload HTML artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: developer-guide-html | ||
| path: build/developer-guide/developer-guide-html.zip | ||
| if-no-files-found: error | ||
|
|
||
| - name: Upload PDF artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: developer-guide-pdf | ||
| path: build/developer-guide/pdf/developer-guide.pdf | ||
| if-no-files-found: error | ||
|
|
||
| - name: Comment with artifact download links | ||
| if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork }} | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const marker = '<!-- developer-guide-artifacts -->'; | ||
| const { owner, repo } = context.repo; | ||
| const runId = context.runId; | ||
| const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
| owner, | ||
| repo, | ||
| run_id: runId, | ||
| per_page: 100 | ||
| }); | ||
|
|
||
| const links = []; | ||
| for (const artifact of artifacts.data.artifacts) { | ||
| if (artifact.name === 'developer-guide-html') { | ||
| links.push(`- [Developer Guide HTML package](https://github.com/${owner}/${repo}/actions/runs/${runId}/artifacts/${artifact.id})`); | ||
| } | ||
| if (artifact.name === 'developer-guide-pdf') { | ||
| links.push(`- [Developer Guide PDF](https://github.com/${owner}/${repo}/actions/runs/${runId}/artifacts/${artifact.id})`); | ||
| } | ||
| } | ||
|
|
||
| if (!links.length) { | ||
| console.log('No artifacts found to report.'); | ||
| return; | ||
| } | ||
|
|
||
| const body = `${marker}\nDeveloper Guide build artifacts are available for download from this workflow run:\n\n${links.join('\n')}\n`; | ||
| const comments = await github.rest.issues.listComments({ | ||
| owner, | ||
| repo, | ||
| issue_number: context.issue.number, | ||
| per_page: 100 | ||
| }); | ||
|
|
||
| const existing = comments.data.find(comment => comment.body && comment.body.includes(marker)); | ||
|
|
||
| if (existing) { | ||
| await github.rest.issues.updateComment({ | ||
| owner, | ||
| repo, | ||
| comment_id: existing.id, | ||
| body | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number: context.issue.number, | ||
| body | ||
| }); | ||
| } | ||
|
|
||
| - name: Log skipped PR comment | ||
| if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }} | ||
| run: echo "Skipping PR comment because the workflow run does not have permission to post on forked pull requests." | ||
|
|
||
| - name: Attach artifacts to release | ||
| if: ${{ github.event_name == 'release' && github.event.action == 'published' }} | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| files: | | ||
| build/developer-guide/developer-guide-html.zip | ||
| build/developer-guide/pdf/developer-guide.pdf | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow tries to call
issues.createCommentusing the defaultGITHUB_TOKENwhenever it runs on a pull request. For PRs opened from forks, that token is read‑only and cannot write to issues or PRs. When such a forked PR touches the developer guide, this step will consistently fail with a 403, causing the entire workflow to report failure even though the documentation build succeeded and no comment was required. Consider guarding the comment step behind a permission check, switching topull_request_target, or marking the stepcontinue-on-errorso forked contributions do not see a failing check.Useful? React with 👍 / 👎.