Skip to content

Commit 52c2047

Browse files
committed
ci: Add preview cookbook workflow
Add a new workflow file to enable previewing the cookbook. This workflow runs on pull requests and creates a preview of the cookbook using mdBook. The preview is then uploaded as an artifact and a comment is created in the pull request to notify users.
1 parent 536871e commit 52c2047

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: preview cookbook
2+
3+
on:
4+
pull_request: {}
5+
workflow_dispatch: null
6+
7+
jobs:
8+
preview-cookbook:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
# For the comment in the PRs saying that the preview is ready.
12+
issues: write
13+
pull-requests: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
submodules: true # could be useful in the future
18+
fetch-depth: 0 # we just need the latest commit
19+
20+
- name: Setup mdBook
21+
uses: peaceiris/actions-mdbook@v2
22+
with:
23+
mdbook-version: 'latest'
24+
25+
- name: Build mdbook
26+
working-directory: ./cookbook
27+
run: mdbook build
28+
29+
- name: Make preview available
30+
if: ${{ github.event_name == 'pull_request' }}
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: cookbook-preview
34+
path: ./cookbook/book
35+
retention-days: 8
36+
37+
- name: Create a comment to say that the artifact is ready
38+
if: ${{ github.event_name == 'pull_request' }}
39+
uses: peter-evans/create-or-update-comment@v4
40+
with:
41+
issue-number: ${{ github.event.number }}
42+
body: |
43+
The cookbook mdbook was created and uploaded as an artifact. \
44+
You can find it on the GitHub Actions Summary page for the GitHub Actions Runs in this PR.

0 commit comments

Comments
 (0)