Repository navigation
99 lines (87 loc) · 4.06 KB
/
Copy pathdeploy_docs.yml
File metadata and controls
99 lines (87 loc) · 4.06 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
name: Deploy Versioned Docs
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'docs/**'
- 'mkdocs.yml'
release:
types: [published, released]
permissions:
contents: write
jobs:
deploy-docs:
# A full release fires "published" and "released" and only "released" deploys it. Skipping the
# other run keeps it out of the queue, where it would replace a pending deploy.
if: github.event_name != 'release' || github.event.action == 'released' || github.event.release.prerelease
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: pip install "mkdocs-material==9.5.19" "mike==2.1.3" "mkdocs-redirects==1.2.2"
- name: Configure Git for mike
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Release tags must be chart versions: the docs stamp the tag into `helm --version` and CRD URLs.
- name: Check release tag matches chart version
if: github.event_name == 'release'
env:
TAG: ${{ github.event.release.tag_name }}
run: |
CHART_VERSION=$(sed -nE 's/^version:[[:space:]]*"?([^"[:space:]]+)"?.*/\1/p' operator/documentdb-helm-chart/Chart.yaml)
if [[ "$TAG" != "$CHART_VERSION" ]]; then
echo "::error::Release tag '$TAG' does not match Chart.yaml version '$CHART_VERSION'"
exit 1
fi
# Dev docs get main's chart version so copied commands stay runnable.
- name: Stamp chart version into dev docs
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
run: |
CHART_VERSION=$(sed -nE 's/^version:[[:space:]]*"?([^"[:space:]]+)"?.*/\1/p' operator/documentdb-helm-chart/Chart.yaml)
find docs/operator-public-documentation -name '*.md' -exec sed -i "s|<release-version>|${CHART_VERSION}|g" {} +
- name: Stamp release version into docs
if: github.event_name == 'release'
run: |
VERSION=${{ github.event.release.tag_name }}
find docs/operator-public-documentation -name '*.md' -exec sed -i "s|<release-version>|${VERSION}|g" {} +
- name: Check documentation entrypoints before publishing
run: |
python -m unittest discover -s .github/scripts -p '*_test.py'
mkdocs build
python .github/scripts/check_doc_links.py --site-dir site
# On push to main: deploy as "dev" version
- name: Deploy dev docs
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
run: mike deploy dev --push --update-aliases
# On release: deploy versioned docs and update "latest" alias
# "released" also fires when a prerelease is later marked as a release.
- name: Deploy release docs
if: github.event_name == 'release'
env:
ACTION: ${{ github.event.action }}
PRERELEASE: ${{ github.event.release.prerelease }}
run: |
VERSION=${{ github.event.release.tag_name }}
# A prerelease must not take over the "latest" docs that external links point at.
if [[ "$ACTION" == "published" && "$PRERELEASE" == "true" ]]; then
mike deploy ${VERSION} --push
elif [[ "$ACTION" == "released" ]]; then
mike deploy ${VERSION} latest --push --update-aliases
mike set-default latest --push
fi
- name: Verify published stable documentation links
if: github.event_name == 'release' && github.event.action == 'released' && !github.event.release.prerelease
timeout-minutes: 5
run: python .github/scripts/check_doc_links.py --attempts 12