1
1
name : Generate and upload Hugo docs
2
2
3
3
on :
4
+ # Only run the workflow on changes to the following paths
4
5
push :
5
6
branches : master
7
+ pull_request :
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
+ concurrency :
17
+ group : ${{ github.workflow }}-${{ github.ref }}
18
+ env :
19
+ DEP : ${{ vars.PREVIEW_HUGO_DOCS }}
11
20
12
21
steps :
13
22
- name : Checkout code
@@ -18,13 +27,19 @@ jobs:
18
27
with :
19
28
hugo-version : ' 0.127.0'
20
29
21
- - name : Build
30
+ - name : Build with defaults from doc/hugo.yml for the xapi-project/xen-api master
31
+ if : |
32
+ github.repository == 'xapi-project/xen-api' &&
33
+ github.ref == 'refs/heads/master'
22
34
run : |
23
35
cd doc
24
36
hugo --minify
25
37
26
- - name : Deploy
38
+ - name : Deploy xapi-project/xen-api master to https://xapi-project.github.io/new-docs
27
39
uses : peaceiris/actions-gh-pages@v4
40
+ if : |
41
+ github.repository == 'xapi-project/xen-api' &&
42
+ github.ref == 'refs/heads/master'
28
43
with :
29
44
deploy_key : ${{ secrets.ACTIONS_DOCS_DEPLOY_KEY }}
30
45
publish_dir : ./doc/public
35
50
destination_dir : new-docs # temporary staging branch
36
51
allow_empty_commit : false
37
52
enable_jekyll : true # do not create .nojekyll file
53
+
54
+ - name : Build to deploy to a clone's GitHub Pages for documentation update reviews
55
+ if : ${{ vars.PREVIEW_HUGO_DOCS == 'true' || env.DEP == 'true' }}
56
+ env :
57
+ # Override the Hugo baseUrl in doc/hugo.toml with the repo name for doc reviews:
58
+ HUGO_BASEURL : ${{ steps.deployment.outputs.page_url }}
59
+ run : cd doc;hugo --minify
60
+
61
+
62
+ # When pushed to other repositories, deploy to the repository's GitHub Pages
63
+ preview-docs :
64
+ # Add a dependency to the hugo job, skip if the hugo job did not complete
65
+ needs : hugo
66
+
67
+ # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
68
+ permissions :
69
+ id-token : write # Required for the deployment job to access the uploaded artifact
70
+ pages : write # Required for the deployment job to deploy to GitHub Pages
71
+
72
+ # Deploy to the github-pages environment for doc reviews
73
+ # This variable is used in the preview-docs job to determine whether to preview the Hugo docs
74
+ # You can set this variable in the repository's environment or secrets settings:
75
+ if : vars.PREVIEW_HUGO_DOCS
76
+ environment :
77
+ name : github-pages
78
+ url : ${{ steps.deployment.outputs.page_url }}
79
+
80
+ # Specify runner + deployment step
81
+ runs-on : ubuntu-latest
82
+ steps :
83
+ - name : Upload Hugo static site as an artifact for documentation update reviews
84
+ uses : actions/upload-pages-artifact@v3
85
+ with :
86
+ path : ./doc/public
87
+
88
+ - name : Deploy uploaded artifact to GitHub Pages for documentation update reviews
89
+ id : deployment
90
+ uses : actions/deploy-pages@v4
0 commit comments