Skip to content

Commit 5a57839

Browse files
committed
GitHub actions: deployment to GitHub Pages, link check
* added workflow files * README.md: - added section on deployment via GitHub pages - added section on automated link checking
1 parent 6d63a21 commit 5a57839

File tree

6 files changed

+1718
-4
lines changed

6 files changed

+1718
-4
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deployment on GitHub Pages
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
# uncomment line below for automatic deployment on push
8+
# - master # <- Set branch used for deployment
9+
pull_request:
10+
11+
env:
12+
REPO_NAME: ${{ github.event.repository.name }}
13+
REPO_OWNER: ${{ github.repository_owner }}
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-22.04
18+
concurrency:
19+
group: deployment-${{ github.ref }}
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
24+
25+
- name: Setup Hugo
26+
uses: peaceiris/actions-hugo@v2
27+
with:
28+
hugo-version: '0.110.0'
29+
extended: true
30+
31+
- name: Setup Node
32+
uses: actions/setup-node@v3
33+
with:
34+
node-version: '18'
35+
cache: 'npm'
36+
# The action defaults to search for the dependency file (package-lock.json,
37+
# npm-shrinkwrap.json or yarn.lock) in the repository root, and uses its
38+
# hash as a part of the cache key.
39+
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
40+
cache-dependency-path: '**/package-lock.json'
41+
42+
- run: npm ci
43+
- run: hugo --baseURL https://${REPO_OWNER}.github.io/${REPO_NAME} --minify
44+
45+
- name: Deployment
46+
uses: peaceiris/actions-gh-pages@v3
47+
if: ${{ github.ref == 'refs/heads/master' }} # <- must be same branch as given above
48+
with:
49+
github_token: ${{ secrets.GITHUB_TOKEN }}
50+
publish_dir: ./public

.github/workflows/link-check.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Link check
2+
3+
on:
4+
workflow_call:
5+
push:
6+
branches:
7+
- master # <- Set branch used for deployment
8+
pull_request:
9+
10+
workflow_dispatch:
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-22.04
15+
concurrency:
16+
group: link-check-${{ github.ref }}
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
21+
22+
- name: Setup Hugo
23+
uses: peaceiris/actions-hugo@v2
24+
with:
25+
hugo-version: '0.110.0'
26+
extended: true
27+
28+
- name: Setup Node
29+
uses: actions/setup-node@v3
30+
with:
31+
node-version: '18'
32+
cache: 'npm'
33+
# The action defaults to search for the dependency file (package-lock.json,
34+
# npm-shrinkwrap.json or yarn.lock) in the repository root, and uses its
35+
# hash as a part of the cache key.
36+
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
37+
cache-dependency-path: '**/package-lock.json'
38+
39+
- run: npm ci
40+
- run: hugo --baseURL '' --minify
41+
42+
- name: Link check
43+
uses: untitaker/[email protected]
44+
if: ${{ github.ref == 'refs/heads/master' }} # <- must be same branch as given above
45+
with:
46+
args: public/ # --check-anchors

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/public
22
resources/
33
node_modules/
4-
package-lock.json
54
.hugo_build.lock

README.md

+30-3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,28 @@ Once you've made your working copy of the site repo, from the repo root folder,
6161
hugo server
6262
```
6363

64+
## Deployment on GitHub pages
65+
66+
This repo ships with a [GitHub action] that allows you to deploy your site to [GitHub Pages].
67+
To manually trigger the deployment, select the [deployment workflow] in the `Actions` section of the GitHub web UI and press the button `Run workflow`.
68+
To enable automatic deployment on each push to your repo, edit the corresponding [workflow file](.github/workflows/deploy-github-pages.yml) and uncomment the line specifying the branch used for deployment:
69+
70+
```yml
71+
on:
72+
workflow_dispatch: # enables manual run of workflow via GitHub web UI
73+
push:
74+
branches:
75+
- master # <- Set branch used for deployment here
76+
```
77+
78+
For further details on the deployment setup, please refer to the [deployment] section of the docsy user guide.
79+
80+
## Automated link check
81+
82+
This repo ships with a [GitHub action] that allows you to check the internal links of your page using the fast [hyperlink] link checker.
83+
By default, the link check action will be performed on each push to your repo. To see the results of the last workflow run(s), select the [link check workflow] in the `Actions` section of the GitHUB web UI.
84+
On the same page, you can also disable the workflow if needed. To do so, press the button `…` right beneath the search field that allows you to filter workflow runs.
85+
6486
## Running a container locally
6587

6688
You can run docsy-example inside a [Docker](https://docs.docker.com/)
@@ -140,9 +162,8 @@ $ hugo server
140162
Error: failed to download modules: binary with name "go" not found
141163
```
142164

143-
This error occurs if you have not installed the `go` programming language on your system.
144-
See this [section](https://www.docsy.dev/docs/get-started/docsy-as-module/installation-prerequisites/#install-go-language) of the user guide for instructions on how to install `go`.
145-
165+
This error occurs if the `go` programming language is not available on your system.
166+
Go to the [download area] of the Go website, choose the installer for your system architecture and execute it.
146167

147168
[alternate dashboard]: https://app.netlify.com/sites/goldydocs/deploys
148169
[deploys]: https://app.netlify.com/sites/docsy-example/deploys
@@ -152,3 +173,9 @@ See this [section](https://www.docsy.dev/docs/get-started/docsy-as-module/instal
152173
[Hugo theme module]: https://gohugo.io/hugo-modules/use-modules/#use-a-module-for-a-theme
153174
[Netlify]: https://netlify.com
154175
[Docker Compose documentation]: https://docs.docker.com/compose/gettingstarted/
176+
[GitHub action]: https://docs.github.com/en/actions
177+
[deployment]: https://docsy.dev/docs/deployment/#deployment-on-github-pages
178+
[deployment workflow]: ../../actions/workflows/deploy-github-pages.yml
179+
[link check workflow]: ../../actions/workflows/link-check.yml
180+
[hyperlink]: https://github.com/untitaker/hyperlink
181+
[download area]: https://go.dev/dl/

hugo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
baseURL = "/"
2+
# For deployment on GitHub Pages:
3+
# baseURL = "https://<USERNAME>.github.io/<repository_name>"
4+
25
title = "Goldydocs"
36

47
# Language settings

0 commit comments

Comments
 (0)