-
Notifications
You must be signed in to change notification settings - Fork 141
149 lines (126 loc) · 4.5 KB
/
documentation.yml
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Build Documentation
on:
push:
tags-ignore:
- "v*"
pull_request:
release:
types:
- published
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: "recursive"
- name: Update system packages
run: sudo apt-get update -y
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install Python dependencies and update cert
run: |
pip install wheel boto3 && \
pip install certifi -U && \
pip install .[obj,dev]
- name: Resolve the target CLI version
uses: actions/github-script@v7
id: resolve-cli-version
with:
script: |
const latest_release = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
if (context.payload.release && latest_release.data.id == context.payload.release.id) {
let result = context.payload.release.tag_name;
if (result.startsWith('v')) {
result = result.slice(1);
}
return result;
}
return '0.0.0.dev+' + context.sha.substring(0, 7);
result-encoding: string
- name: Build the documentation
run: make create-version && make generate-docs
env:
# We need to define a token to prevent the CLI from
# attempting to do a first-time configuration.
LINODE_CLI_TOKEN: foobar
LINODE_CLI_VERSION: ${{ steps.resolve-cli-version.outputs.result }}
- name: Upload the artifact
uses: actions/upload-artifact@v4
with:
name: generated-docs-html
path: docs/build/html
pages-commit:
name: Commit to Pages Branch
runs-on: ubuntu-latest
needs:
- build
# Make sure we avoid a race condition =)
concurrency:
group: "docs-stage"
cancel-in-progress: false
permissions:
contents: write
if: (github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'new/doc-generation' )) || (github.ref_type == 'tag')
steps:
- name: Checkout the documentation branch
continue-on-error: true
id: checkout-docs
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: "recursive"
ref: "_documentation"
- name: Create the documentation branch if it does not already exist
if: "${{ steps.checkout-docs.outcome != 'success' }}"
run: git switch --orphan _documentation
- name: Ensure any previous documentation for this branch is removed
run: rm -rf "./${{ github.ref_name }}"
- name: Download the artifact from the build job
uses: actions/download-artifact@v4
with:
name: generated-docs-html
path: "${{ github.ref_name }}"
- name: Override the latest version if necessary
if: ${{ github.ref_type == 'tag' }}
run: |
rm -rf latest && cp -r ${{ github.ref_name }} latest
- name: Overlay static files
run: |
echo "<head><meta http-equiv='refresh' content='0; URL=latest/index.html'></head>" > index.html;
touch .nojekyll
- name: Commit and push this change
run: |
git config user.name "Documentation Publisher";
git config user.email "[email protected]";
git add .;
git commit --allow-empty -m "Build ${{ github.ref_name }} from ${{ github.sha }}";
git push origin _documentation;
upload-release-asset:
name: Upload Release Asset
runs-on: ubuntu-latest
needs:
- build
if: github.ref_type == 'tag'
steps:
- name: Download the artifact from the previous job
uses: actions/download-artifact@v4
with:
name: generated-docs-html
path: ".build/${{ github.ref_name }}"
- name: Archive the built documentation
run: |
cd .build/${{ github.ref_name }} && tar -czvf ../documentation.tar.gz *
- name: Upload the documentation as a release asset
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
with:
files: .build/documentation.tar.gz
tag_name: ${{ github.ref_name }}