Skip to content

Commit 25aeb03

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 2112cfb commit 25aeb03

8 files changed

+1727
-11
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

+31-3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,28 @@ Once you've made your working copy of the site repo, from the repo root folder,
5959
hugo server
6060
```
6161

62+
## Deployment on GitHub pages
63+
64+
This repo ships with a [GitHub action] that allows you to deploy your site to [GitHub Pages].
65+
To manually trigger the deployment, select the [deployment workflow] in the `Actions` section of the GitHub web UI and press the button `Run workflow`.
66+
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:
67+
68+
```yml
69+
on:
70+
workflow_dispatch: # enables manual run of workflow via GitHub web UI
71+
push:
72+
branches:
73+
- master # <- Set branch used for deployment here
74+
```
75+
76+
For further details on the deployment setup, please refer to the [deployment] section of the docsy user guide.
77+
78+
## Automated link check
79+
80+
This repo ships with a [GitHub action] that allows you to check the internal links of your page using the fast [hyperlink] link checker.
81+
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.
82+
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.
83+
6284
## Running a container locally
6385

6486
You can run docsy-example inside a [Docker](https://docs.docker.com/)
@@ -125,9 +147,8 @@ Or you may encounter the following error:
125147
Error: failed to download modules: binary with name "go" not found
126148
```
127149

128-
This error occurs if you have not installed the `go` programming language on your system.
129-
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`.
130-
150+
This error occurs if the `go` programming language is not available on your system.
151+
Go to the [download area] of the Go website, choose the installer for your system architecture and execute it.
131152

132153
[alternate dashboard]: https://app.netlify.com/sites/goldydocs/deploys
133154
[deploys]: https://app.netlify.com/sites/docsy-example/deploys
@@ -136,3 +157,10 @@ See this [section](https://www.docsy.dev/docs/get-started/docsy-as-module/instal
136157
[example.docsy.dev]: https://example.docsy.dev
137158
[Hugo theme module]: https://gohugo.io/hugo-modules/use-modules/#use-a-module-for-a-theme
138159
[Netlify]: https://netlify.com
160+
[GitHub Pages]: https://docs.github.com/en/pages
161+
[GitHub action]: https://docs.github.com/en/actions
162+
[deployment]: https://docsy.dev/docs/deployment/#deployment-on-github-pages
163+
[deployment workflow]: ../../actions/workflows/deploy-github-pages.yml
164+
[link check workflow]: ../../actions/workflows/link-check.yml
165+
[hyperlink]: https://github.com/untitaker/hyperlink
166+
[download area]: https://go.dev/dl/

config.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

netlify.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[build]
22
[build.environment]
3-
HUGO_VERSION = "0.104.3"
4-
GO_VERSION = "1.19.2"
3+
NODE_VERSION = "18.14.2"
4+
HUGO_VERSION = "0.110.0"
5+
GO_VERSION = "1.20.1"

0 commit comments

Comments
 (0)