Skip to content

Commit e026ab7

Browse files
committed
Add workflow to build developer guide documentation
1 parent 0dc108c commit e026ab7

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Build Developer Guide Docs
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'docs/developer-guide/**'
7+
- '.github/workflows/developer-guide-docs.yml'
8+
release:
9+
types: [published]
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
issues: write
18+
pull-requests: write
19+
actions: read
20+
steps:
21+
- name: Check out repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Ruby
25+
uses: ruby/setup-ruby@v1
26+
with:
27+
ruby-version: '3.1'
28+
29+
- name: Install Asciidoctor tooling
30+
run: |
31+
gem install --no-document asciidoctor asciidoctor-pdf
32+
33+
- name: Build Developer Guide HTML and PDF
34+
run: |
35+
OUTPUT_DIR="build/developer-guide"
36+
mkdir -p "$OUTPUT_DIR"
37+
asciidoctor -D "$OUTPUT_DIR" -o developer-guide.html docs/developer-guide/developer-guide.asciidoc
38+
asciidoctor-pdf -D "$OUTPUT_DIR" -o developer-guide.pdf docs/developer-guide/developer-guide.asciidoc
39+
40+
- name: Upload HTML artifact
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: developer-guide-html
44+
path: build/developer-guide/developer-guide.html
45+
if-no-files-found: error
46+
47+
- name: Upload PDF artifact
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: developer-guide-pdf
51+
path: build/developer-guide/developer-guide.pdf
52+
if-no-files-found: error
53+
54+
- name: Comment with artifact download links
55+
if: ${{ github.event_name == 'pull_request' }}
56+
uses: actions/github-script@v7
57+
with:
58+
github-token: ${{ secrets.GITHUB_TOKEN }}
59+
script: |
60+
const marker = '<!-- developer-guide-artifacts -->';
61+
const { owner, repo } = context.repo;
62+
const runId = context.runId;
63+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
64+
owner,
65+
repo,
66+
run_id: runId,
67+
per_page: 100
68+
});
69+
70+
const links = [];
71+
for (const artifact of artifacts.data.artifacts) {
72+
if (artifact.name === 'developer-guide-html') {
73+
links.push(`- [Developer Guide HTML](https://github.com/${owner}/${repo}/actions/runs/${runId}/artifacts/${artifact.id})`);
74+
}
75+
if (artifact.name === 'developer-guide-pdf') {
76+
links.push(`- [Developer Guide PDF](https://github.com/${owner}/${repo}/actions/runs/${runId}/artifacts/${artifact.id})`);
77+
}
78+
}
79+
80+
if (!links.length) {
81+
console.log('No artifacts found to report.');
82+
return;
83+
}
84+
85+
const body = `${marker}\nDeveloper Guide build artifacts are available for download from this workflow run:\n\n${links.join('\n')}\n`;
86+
const comments = await github.rest.issues.listComments({
87+
owner,
88+
repo,
89+
issue_number: context.issue.number,
90+
per_page: 100
91+
});
92+
93+
const existing = comments.data.find(comment => comment.body && comment.body.includes(marker));
94+
95+
if (existing) {
96+
await github.rest.issues.updateComment({
97+
owner,
98+
repo,
99+
comment_id: existing.id,
100+
body
101+
});
102+
} else {
103+
await github.rest.issues.createComment({
104+
owner,
105+
repo,
106+
issue_number: context.issue.number,
107+
body
108+
});
109+
}
110+
111+
- name: Attach artifacts to release
112+
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
113+
uses: softprops/action-gh-release@v1
114+
with:
115+
files: |
116+
build/developer-guide/developer-guide.html
117+
build/developer-guide/developer-guide.pdf

0 commit comments

Comments
 (0)