forked from linode/linode-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (117 loc) · 4.02 KB
/
publish-docs.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
name: Build Documentation
on:
push:
branches:
- dev
- main
- new/doc-generation
pull_request:
release:
types:
- published
jobs:
build:
name: Build the documentation
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: |
let latest_release = github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
if (context.payload.release && latest_release.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
- run: echo
publish:
name: Publish the documentation
runs-on: ubuntu-latest
needs:
- build
# Make sure we avoid a race condition =)
concurrency:
group: "pages"
cancel-in-progress: false
permissions:
contents: write
pages: write
id-token: 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: "static/docs"
- name: Create the documentation branch if it does not already exist
if: "${{ steps.checkout-docs.outcome != 'success' }}"
run: git switch --orphan static/docs
- name: Ensure any previous documentation for this branch are removed
run: rm -rf "./${{ github.ref_name }}"
- name: Download the artifact from the previous job
uses: actions/download-artifact@v4
with:
name: generated-docs-html
path: "${{ github.ref_name }}"
- name: Override the latest version if necessary
if: ${{ github.event_name == 'release' }}
run: |
rm -f latest && ln -s ${{ github.ref_name }} latest
- 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 "Rebuild ${{ github.ref_name }} from ${{ github.sha }}";
git push origin static/docs;
- name: Configure GitHub Pages
uses: actions/configure-pages@v5
with:
enablement: true
- name: Push the rendered documentation site to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: .
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4