Repository navigation
127 lines (113 loc) · 5.07 KB
/
Copy pathdocs.yml
File metadata and controls
127 lines (113 loc) · 5.07 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
118
119
120
121
122
123
124
125
126
127
---
name: MkDocs
on:
workflow_call:
inputs:
version:
description: "Project version (for releases)"
required: false
type: string
release_type:
description: "Type of release"
required: true
type: string
default: "latest"
# The choice type isn't available for workflow_call, but we
# generally expect the following values here:
# - "latest"
# - "release"
# - "preview"
# - "build-only" # no publish, doesn't require secrets / write access
env:
PYTHON_VERSION: "3.13"
jobs:
mkdocs:
runs-on: ubuntu-latest
steps:
- name: Validate relese type input
if: inputs.release_type != 'latest' && inputs.release_type != 'release' && inputs.release_type != 'preview' && inputs.release_type != 'build-only'
run: |
echo "ERROR: release_type must be one of: 'latest', 'release', 'preview' or 'build-only'"
exit 1
- name: Validate version input
if: inputs.release_type == 'release' && inputs.version == ''
run: |
echo "ERROR: version must be set for release builds"
exit 1
- name: Generate token
id: app-token
if: inputs.release_type != 'build-only'
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.PYMINE_BOT_APP_ID }}
private-key: ${{ secrets.PYMINE_BOT_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
- name: Checkout repository
uses: actions/checkout@v6
with:
# Clone with the token generated above, as it will allow push access to the repo
# If the above step was skipped, the token string will be empty, this is fine,
# it will just perform an unauthenticated anonymous public clone.
token: "${{ steps.app-token.outputs.token }}"
# Fetch the entire git history (all branches + tags)
# We do this because the docs use git describe, which requires having all
# the commits up to the latest version tag.
# We also need the gh-pages branch to push the docs to.
fetch-depth: 0
# Make the github application be the committer
# (see: https://stackoverflow.com/a/74071223 on how to obtain the committer email)
- name: Setup git config
if: inputs.release_type != 'build-only'
run: |
git config --global user.name "py-mine-ci-bot"
git config --global user.email "121461646+py-mine-ci-bot[bot]@users.noreply.github.com"
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
version: "latest"
python-version: ${{ env.PYTHON_VERSION }}
activate-environment: true
enable-cache: true
cache-suffix: "docs"
- name: Install dependencies
run: uv sync --no-default-groups --group docs
- name: Build the documentation (mkdocs)
# Only build with mkdocs if we won't be using mike to deploy
# (since mike also performs building - it adjust the build to add versions)
if: inputs.release_type == 'build-only' || inputs.release_type == 'preview'
run: mkdocs build
- name: Build & Publish release docs (mike)
if: inputs.release_type == 'release'
env:
version: ${{ inputs.version }}
run: mike deploy --update-aliases "$version" release
- name: Build & Publish latest docs (mike)
if: inputs.release_type == 'latest'
run: mike deploy latest
- name: Deploy docs - PR preview
if: inputs.release_type == 'preview'
id: pr-preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: ./site
preview-branch: gh-pages
umbrella-dir: pr-preview
token: ${{ steps.app-token.outputs.token }}
comment: false # see: https://github.com/rossjrw/pr-preview-action/issues/118
# This just mimics comment: true behavior, except with the correct token
# as rossjrw/pr-preview-action@v1 isn't respecting token for sending the comment
# (https://github.com/rossjrw/pr-preview-action/issues/118)
- name: Leave a sticky PR comment after preview deployment
uses: marocchino/sticky-pull-request-comment@v3
with:
header: pr-preview
message: |
[PR Preview Action](https://github.com/${{ env.action_repository }}) ${{ env.action_version }}
:---:
| <p></p> :rocket: View preview at <br> ${{ steps.pr-preview.outputs.preview-url }} <br><br>
| <h6>Built to branch [`gh-pages`](${{ github.server_url }}/${{ github.repository }}/tree/gh-pages) at ${{ steps.pr-preview.outputs.action-start-timestamp }}. <br> Preview will be ready when the [GitHub Pages deployment](${{ github.server_url }}/${{ github.repository }}/deployments) is complete. <br><br> </h6>
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Push Documentation
if: inputs.release_type == 'latest' || inputs.release_type == 'release'
run: git push origin gh-pages