1+ # Workflow to build your docs with oranda (and mdbook)
2+ # and deploy them to Github Pages
3+ name : Web
4+
5+ # We're going to push to the gh-pages branch, so we need that permission
6+ permissions :
7+ contents : write
8+
9+ # What situations do we want to build docs in?
10+ # All of these work independently and can be removed / commented out
11+ # if you don't want oranda/mdbook running in that situation
12+ on :
13+ # Check that a PR didn't break docs!
14+ #
15+ # Note that the "Deploy to Github Pages" step won't run in this mode,
16+ # so this won't have any side-effects. But it will tell you if a PR
17+ # completely broke oranda/mdbook. Sadly we don't provide previews (yet)!
18+ pull_request :
19+
20+ # Whenever something gets pushed to main, update the docs!
21+ # This is great for getting docs changes live without cutting a full release.
22+ #
23+ # Note that if you're using cargo-dist, this will "race" the Release workflow
24+ # that actually builds the Github Release that oranda tries to read (and
25+ # this will almost certainly complete first). As a result you will publish
26+ # docs for the latest commit but the oranda landing page won't know about
27+ # the latest release. The workflow_run trigger below will properly wait for
28+ # cargo-dist, and so this half-published state will only last for ~10 minutes.
29+ #
30+ # If you only want docs to update with releases, disable this, or change it to
31+ # a "release" branch. You can, of course, also manually trigger a workflow run
32+ # when you want the docs to update.
33+ push :
34+ branches :
35+ - main
36+
37+ # Whenever a workflow called "Release" completes, update the docs!
38+ #
39+ # If you're using cargo-dist, this is recommended, as it will ensure that
40+ # oranda always sees the latest release right when it's available. Note
41+ # however that Github's UI is wonky when you use workflow_run, and won't
42+ # show this workflow as part of any commit. You have to go to the "actions"
43+ # tab for your repo to see this one running (the gh-pages deploy will also
44+ # only show up there).
45+ workflow_run :
46+ workflows : [ "Release" ]
47+ types :
48+ - completed
49+
50+ # Alright, let's do it!
51+ jobs :
52+ web :
53+ name : Build and deploy site and docs
54+ runs-on : ubuntu-latest
55+ steps :
56+ # Setup
57+ - uses : actions/checkout@v3
58+ with :
59+ fetch-depth : 0
60+ - uses : dtolnay/rust-toolchain@stable
61+ - uses : swatinem/rust-cache@v2
62+
63+ # If you use any mdbook plugins, here's the place to install them!
64+
65+ # Install and run oranda (and mdbook)
66+ # This will write all output to ./public/ (including copying mdbook's output to there)
67+ - name : Install and run oranda
68+ run : |
69+ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/download/v0.3.1/oranda-installer.sh | sh
70+ oranda build
71+
72+ - name : Prepare HTML for link checking
73+ # untitaker/hyperlink supports no site prefixes, move entire site into
74+ # a subfolder
75+ run : mkdir /tmp/public/ && cp -R public /tmp/public/oranda
76+
77+ - name : Check HTML for broken internal links
78+ 79+ with :
80+ args : /tmp/public/ --sources docs/
81+
82+ # Deploy to our gh-pages branch (creating it if it doesn't exist)
83+ # the "public" dir that oranda made above will become the root dir
84+ # of this branch.
85+ #
86+ # Note that once the gh-pages branch exists, you must
87+ # go into repo's settings > pages and set "deploy from branch: gh-pages"
88+ # the other defaults work fine.
89+ - name : Deploy to Github Pages
90+ 91+ # ONLY if we're on main (so no PRs or feature branches allowed!)
92+ if : ${{ github.ref == 'refs/heads/main' }}
93+ with :
94+ branch : gh-pages
95+ # Gotta tell the action where to find oranda's output
96+ folder : public
97+ token : ${{ secrets.GITHUB_TOKEN }}
98+ single-commit : true
0 commit comments