@@ -3,11 +3,21 @@ name: Generate and upload Hugo docs
3
3
on :
4
4
push :
5
5
branches : master
6
+ pull_request :
7
+ # Only run the workflow on changes to the following paths
8
+ paths :
9
+ - ' doc/**'
10
+ - ' .github/workflows/hugo.yml'
6
11
7
12
jobs :
8
- ocaml :
13
+ hugo :
9
14
name : Docs
10
15
runs-on : ubuntu-22.04
16
+ environment :
17
+ # To be able read var.PREVIEW_HUGO_DOCS, if set in the github-pages environment:
18
+ name : github-pages
19
+ outputs :
20
+ preview : ${{ steps.preview.outputs.done }} # Set to true if the preview job runs
11
21
12
22
steps :
13
23
- name : Checkout code
25
35
26
36
- name : Deploy
27
37
uses : peaceiris/actions-gh-pages@v4
38
+ # The deploy key used for deployment to https://xenapi-project.github.io
39
+ # It is stored in the repository's secrets and is used to push the built
40
+ # documentation. This step skips deployment if it is not set on a clone.
28
41
with :
29
42
deploy_key : ${{ secrets.ACTIONS_DOCS_DEPLOY_KEY }}
30
43
publish_dir : ./doc/public
35
48
destination_dir : new-docs # temporary staging branch
36
49
allow_empty_commit : false
37
50
enable_jekyll : true # do not create .nojekyll file
51
+
52
+ # Deploy to the github-pages environment for doc reviews in other repositories
53
+ # if vars.PREVIEW_HUGO_DOCS set by the admin in the repository's environment
54
+ # This is done without commiting to the repository's gh-pages branch, only
55
+ # an artifact is deployed to the clone's github-pages environment instead:
56
+
57
+ - name : If vars.PREVIEW_HUGO_DOCS is true, enable github pages for the preview
58
+ if : ${{ vars.PREVIEW_HUGO_DOCS == 'true' }} # Only runs if set by the admin
59
+ id : configure-pages
60
+ with :
61
+ enablement : true # Enables GitHub Pages for the clone repository
62
+ uses : actions/configure-pages@v5 # output: the base_url for the preview site
63
+
64
+ - name : If vars.PREVIEW_HUGO_DOCS is true, build the hugo preview
65
+ if : ${{ vars.PREVIEW_HUGO_DOCS == 'true' }}
66
+ id : preview
67
+ env :
68
+ # Override the Hugo baseUrl in doc/hugo.toml with the repo name for doc reviews:
69
+ HUGO_BASEURL : ${{ steps.configure-pages.outputs.base_url }}
70
+ run : cd doc && hugo --minify && echo done=true >$GITHUB_OUTPUT
71
+
72
+ - name : If vars.PREVIEW_HUGO_DOCS is true, upload the Hugo site as an artifact
73
+ if : ${{ vars.PREVIEW_HUGO_DOCS == 'true' }}
74
+ uses : actions/upload-pages-artifact@v3
75
+ with :
76
+ path : ./doc/public
77
+
78
+
79
+ # When pushed to other repositories, deploy to the repository's GitHub Pages
80
+ preview-docs :
81
+ # Add a dependency to the hugo job, skip if the hugo job did not complete
82
+ needs : hugo
83
+
84
+ # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
85
+ permissions :
86
+ id-token : write # Required for the deployment job to access the uploaded artifact
87
+ pages : write # Required for the deployment job to deploy to GitHub Pages
88
+
89
+ environment :
90
+ name : github-pages
91
+ url : ${{ steps.deployment.outputs.page_url }}
92
+
93
+ # Specify runner + deployment step
94
+ runs-on : ubuntu-24.04-arm
95
+ steps :
96
+ - name : Deploy uploaded artifact to GitHub Pages for documentation update reviews
97
+ if : ${{ needs.hugo.outputs.preview == 'true' }}
98
+ id : deployment
99
+ uses : actions/deploy-pages@v4
0 commit comments