Skip to content

Commit f53b4f1

Browse files
committed
Add build and deploy actions
1 parent 2a04ce7 commit f53b4f1

File tree

2 files changed

+203
-0
lines changed

2 files changed

+203
-0
lines changed

build/action.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Build hexdoc book
2+
description: Builds a hexdoc book.
3+
author: hexdoc-dev
4+
5+
inputs:
6+
release:
7+
description: "Boolean: if the book should be written to the release path (true) or the latest path (false)"
8+
required: true
9+
python-version:
10+
description: Python version to install
11+
required: false
12+
default: "3.11"
13+
props:
14+
description: Path to your props file (hexdoc.toml or properties.toml)
15+
required: false
16+
pip-extras:
17+
description: Pip extras for your package (eg. "[dev]")
18+
required: false
19+
subdirectory:
20+
description: Subdirectory to deploy the book to
21+
required: false
22+
site-url:
23+
description: Set the base site url instead of looking up the current repo's GitHub Pages url
24+
required: false
25+
pages-artifact:
26+
description: Name of the GitHub Pages artifact to upload
27+
required: false
28+
default: hexdoc-pages
29+
build-artifact:
30+
description: Name of the Python build artifact to upload
31+
required: false
32+
default: hexdoc-build
33+
use-artifacts-v3:
34+
description: If true, use actions/upload-artifact@v3 instead of actions/upload-artifact@v4
35+
required: false
36+
default: "false"
37+
38+
outputs:
39+
pages-url:
40+
description: Current GitHub Pages url for this repo
41+
value: ${{ steps.export.outputs.pages-url }}
42+
release:
43+
description: Value of inputs.release for convenience
44+
value: ${{ inputs.release }}
45+
46+
runs:
47+
using: composite
48+
steps:
49+
- uses: actions/checkout@v3
50+
- uses: actions/setup-python@v4
51+
with:
52+
python-version: ${{ inputs.python-version }}
53+
cache: pip
54+
- uses: yezz123/setup-uv@v4
55+
56+
- name: Install display server
57+
uses: awalsh128/cache-apt-pkgs-action@v1
58+
with:
59+
packages: xvfb
60+
61+
- name: Install Python packages
62+
shell: bash
63+
run: uv pip install --system -e .${{ inputs.pip-extras }} hatch
64+
65+
- name: Build web book
66+
id: export
67+
env:
68+
HEXDOC_PROPS: ${{ inputs.props }}
69+
HEXDOC_RELEASE: ${{ inputs.release }}
70+
HEXDOC_SUBDIRECTORY: ${{ inputs.subdirectory }}
71+
GITHUB_PAGES_URL: ${{ inputs.site-url }}
72+
shell: bash
73+
run: xvfb-run --auto-servernum hexdoc ci build
74+
75+
- name: Zip web book
76+
working-directory: _site/src/docs
77+
shell: bash
78+
run: zip site.zip ./* -r
79+
80+
- name: Upload intermediate Pages artifact (v4)
81+
if: inputs.use-artifacts-v3 != 'true'
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: ${{ inputs.pages-artifact }}
85+
path: _site/src/docs/site.zip
86+
87+
- name: Upload package artifact (v4)
88+
if: inputs.use-artifacts-v3 != 'true'
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: ${{ inputs.build-artifact }}
92+
path: dist
93+
94+
- name: Upload intermediate Pages artifact (v3)
95+
if: inputs.use-artifacts-v3 == 'true'
96+
uses: actions/upload-artifact@v3
97+
with:
98+
name: ${{ inputs.pages-artifact }}
99+
path: _site/src/docs/site.zip
100+
101+
- name: Upload package artifact (v3)
102+
if: inputs.use-artifacts-v3 == 'true'
103+
uses: actions/upload-artifact@v3
104+
with:
105+
name: ${{ inputs.build-artifact }}
106+
path: dist
107+
108+
- name: Add job summary
109+
shell: bash
110+
run: echo "Built version \`$(hatch version)\` from commit \`$(git rev-parse --short "$GITHUB_SHA")\`." >> $GITHUB_STEP_SUMMARY

deploy-pages/action.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Deploy hexdoc book to Pages
2+
description: Deploys a hexdoc book to GitHub Pages.
3+
author: hexdoc-dev
4+
5+
inputs:
6+
release:
7+
description: "Boolean: if the book should be written to the release path (true) or the latest path (false)"
8+
required: true
9+
python-version:
10+
description: Python version to install
11+
required: false
12+
default: "3.11"
13+
props:
14+
description: Path to your props file (hexdoc.toml or properties.toml)
15+
required: false
16+
pip-extras:
17+
description: Pip extras for your package (eg. "[dev]")
18+
required: false
19+
subdirectory:
20+
description: Subdirectory to deploy the book to
21+
required: false
22+
site-url:
23+
description: Set the base site url instead of looking up the current repo's GitHub Pages url
24+
required: false
25+
pages-artifact:
26+
description: Name of the GitHub Pages artifact to download
27+
required: false
28+
default: hexdoc-pages
29+
use-artifacts-v3:
30+
description: If true, use actions/download-artifact@v3 instead of actions/download-artifact@v4
31+
required: false
32+
default: "false"
33+
pages-branch:
34+
description: Name of the branch used for GitHub Pages
35+
required: false
36+
default: gh-pages
37+
38+
runs:
39+
using: composite
40+
steps:
41+
- uses: actions/setup-python@v4
42+
with:
43+
python-version: ${{ inputs.python-version }}
44+
cache: pip
45+
- uses: yezz123/setup-uv@v4
46+
47+
- name: Install Python packages
48+
shell: bash
49+
run: uv pip install --system -e .${{ inputs.pip-extras }}
50+
51+
- name: Download Pages artifact (v4)
52+
if: inputs.use-artifacts-v3 != 'true'
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: ${{ inputs.pages-artifact }}
56+
57+
- name: Download Pages artifact (v3)
58+
if: inputs.use-artifacts-v3 == 'true'
59+
uses: actions/download-artifact@v3
60+
with:
61+
name: ${{ inputs.pages-artifact }}
62+
63+
- name: Unzip web book
64+
shell: bash
65+
run: |
66+
mkdir -p _site/src
67+
unzip site.zip -d _site/src/docs
68+
69+
- name: Checkout current Pages
70+
uses: actions/checkout@v3
71+
continue-on-error: true
72+
with:
73+
ref: ${{ inputs.pages-branch }}
74+
path: _site/dst
75+
76+
- name: Merge web book
77+
env:
78+
HEXDOC_PROPS: ${{ inputs.props }}
79+
HEXDOC_RELEASE: ${{ inputs.release }}
80+
HEXDOC_SUBDIRECTORY: ${{ inputs.subdirectory }}
81+
GITHUB_PAGES_URL: ${{ inputs.site-url }}
82+
shell: bash
83+
run: hexdoc ci merge
84+
85+
- name: Deploy to Pages
86+
uses: JamesIves/github-pages-deploy-action@v4
87+
with:
88+
folder: _site/dst/docs/${{ inputs.subdirectory }}
89+
target-folder: docs/${{ inputs.subdirectory }}
90+
clean: true
91+
clean-exclude: |
92+
CNAME
93+
.gitignore

0 commit comments

Comments
 (0)