-
Notifications
You must be signed in to change notification settings - Fork 1.5k
117 lines (99 loc) · 4.27 KB
/
Copy pathdocs-dev.yml
File metadata and controls
117 lines (99 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: dev docs
on:
push:
branches:
- main
# Not filtered by path: the `repo` macro validates documented repository paths while building,
# so renaming a path must fail on the pull request that renames it rather than after merge.
pull_request:
branches:
- main
permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' && true || false }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
# Fetch all history for applying timestamps to every page
fetch-depth: 0
- name: Install dda
uses: ./.github/actions/install-dda
with:
features: legacy-tasks
- name: Configure Git for GitHub Actions bot
run: |
git config --local user.name 'github-actions[bot]'
git config --local user.email 'github-actions[bot]@users.noreply.github.com'
# Cached for resilience rather than speed: the build fetches content from GitHub, so a restored
# cache lets it succeed while GitHub is unreachable. Every URL it fetches is derived from the
# build image pinned in .gitlab-ci.yml, so that file changing is the only reason to fetch again.
- name: Restore fetched documentation content
id: docs-content
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .docs-cache
key: docs-content-${{ hashFiles('.gitlab-ci.yml', 'docs/public/.hooks/inject_variables.py') }}
# Restoring the most recent results, which `cache` in .lychee.toml tells the checker to keep,
# means a host that is briefly unreachable does not fail the run.
- name: Restore link check results
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .lycheecache
key: docs-links-${{ github.run_id }}
restore-keys: docs-links-
- name: Build documentation
run: dda run docs build
# A step of its own, so that a link that rotted on somebody else's site is reported separately
# from documentation that fails to build.
- name: Check links
run: dda run docs check-links
env:
# Authenticated requests to github.com are rate limited far less aggressively.
GITHUB_TOKEN: ${{ github.token }}
# Saving is a separate step because actions/cache only saves when the job succeeds, and a run
# that fails on an unrelated link is exactly when the next one benefits from not fetching again.
- name: Save fetched documentation content
if: always() && steps.docs-content.outputs.cache-hit != 'true'
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .docs-cache
key: docs-content-${{ hashFiles('.gitlab-ci.yml', 'docs/public/.hooks/inject_variables.py') }}
# Separate for the same reason. Pull requests save too: the cache is scoped to the pull request,
# which is what a re-run of it restores.
- name: Save link check results
if: always()
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: .lycheecache
key: docs-links-${{ github.run_id }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: documentation
path: site
publish:
runs-on: ubuntu-latest
permissions:
contents: write
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs:
- build
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: documentation
path: site
- uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: site
commit_message: ${{ github.event.head_commit.message }}
# Write .nojekyll at the root, see:
# https://help.github.com/en/github/working-with-github-pages/about-github-pages#static-site-generators
enable_jekyll: false
# Only deploy if there were changes
allow_empty_commit: false