Repository navigation
171 lines (150 loc) · 5.41 KB
/
Copy pathdeploy-dev-docs-mike.yml
File metadata and controls
171 lines (150 loc) · 5.41 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Docs / Deploy dev-docs with Mike
on:
workflow_call:
inputs:
action:
description: "Mike action to perform: deploy or delete."
required: true
type: string
version_label:
description: "Version label to deploy/delete, e.g. main or 3.0."
required: true
type: string
aliases:
description: "Space-separated aliases to assign on deploy, e.g. latest-release."
required: false
default: ""
type: string
default_label:
description: "If non-empty, run mike set-default with this label or alias after deploy."
required: false
default: ""
type: string
git_tag:
description: "Optional git tag whose deeplabcut package should be checked out before deploying."
required: false
default: ""
type: string
python-version:
description: Python version used for dev docs.
required: false
default: "3.12"
type: string
config-file:
description: MkDocs config file.
required: false
default: "dev-docs/mkdocs.yml"
type: string
deploy-prefix:
description: Mike deploy prefix.
required: false
default: "dev"
type: string
jobs:
mike:
runs-on: ubuntu-latest
permissions:
contents: write
# Unsafe free-text inputs are read from the environment inside `run:`
# rather than spliced in as `${{ }}`.
env:
VERSION_LABEL: ${{ inputs.version_label }}
ALIASES: ${{ inputs.aliases }}
DEFAULT_LABEL: ${{ inputs.default_label }}
GIT_TAG: ${{ inputs.git_tag }}
CONFIG_FILE: ${{ inputs.config-file }}
DEPLOY_PREFIX: ${{ inputs.deploy-prefix }}
steps:
- name: Reject unknown action
if: inputs.action != 'deploy' && inputs.action != 'delete'
shell: bash
run: |
echo "::error::Unsupported action. Expected 'deploy' or 'delete'."
exit 1
- name: Require git_tag for release versions
if: inputs.action == 'deploy' && inputs.version_label != 'main' && inputs.git_tag == ''
shell: bash
run: |
echo "::error::git_tag is required when deploying a version other than main."
exit 1
- name: Refuse to delete the main version
if: inputs.action == 'delete' && inputs.version_label == 'main'
shell: bash
run: |
echo "::error::'main' tracks the repository's latest state and is redeployed on every push; it cannot be deleted."
exit 1
- uses: actions/checkout@v6
with:
fetch-depth: 0
# remove existing checkout to prevent merging a new version into it
- name: Check out tagged package source
if: inputs.git_tag != ''
shell: bash
run: |
rm -rf deeplabcut
git checkout "$GIT_TAG" -- deeplabcut
- name: Check the version is deployed before attempting a delete
if: inputs.action == 'delete'
shell: bash
run: |
git fetch --depth=1 origin gh-pages
versions=$(git show "origin/gh-pages:$DEPLOY_PREFIX/versions.json" | jq -r '.[].version')
if ! grep -qxF "$VERSION_LABEL" <<<"$versions"; then
echo "::error::'$VERSION_LABEL' is not deployed under $DEPLOY_PREFIX/. Deployed: $(tr '\n' ' ' <<<"$versions")"
exit 1
fi
- name: Set up dev-docs environment
uses: ./.github/actions/setup-dev-docs
with:
python-version: ${{ inputs.python-version }}
install-system-deps: ${{ inputs.action != 'delete' }}
- name: Configure git for Mike
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Deploy dev-docs version
if: inputs.action == 'deploy'
shell: bash
run: |
if [ -n "$ALIASES" ]; then
# Unquoted on purpose: aliases is a space-separated list and each
# word becomes its own mike argument.
mike deploy --push \
--config-file "$CONFIG_FILE" \
--deploy-prefix "$DEPLOY_PREFIX" \
--update-aliases \
"$VERSION_LABEL" $ALIASES
else
mike deploy --push \
--config-file "$CONFIG_FILE" \
--deploy-prefix "$DEPLOY_PREFIX" \
"$VERSION_LABEL"
fi
if [ -n "$DEFAULT_LABEL" ]; then
mike set-default --push \
--config-file "$CONFIG_FILE" \
--deploy-prefix "$DEPLOY_PREFIX" \
"$DEFAULT_LABEL"
fi
- name: Delete dev-docs version
if: inputs.action == 'delete'
shell: bash
run: |
mike delete --push \
--config-file "$CONFIG_FILE" \
--deploy-prefix "$DEPLOY_PREFIX" \
"$VERSION_LABEL"
knowledge-index:
# api.jsonl only; docs.jsonl/llms.txt are built by deploy-docs.yml instead.
needs: mike
uses: ./.github/workflows/deploy-knowledge-index.yml
with:
action: ${{ inputs.action }}
version_label: ${{ inputs.version_label }}
git_tag: ${{ inputs.git_tag }}
# The same aliases mike was given, so api.latest follows latest-release.
aliases: ${{ inputs.aliases }}
skip_docs: true
python-version: ${{ inputs.python-version }}
secrets: inherit