Repository navigation
81 lines (77 loc) · 2.72 KB
/
Copy pathpublish-docs.yml
File metadata and controls
81 lines (77 loc) · 2.72 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
name: Publish versioned core documentation
on:
push:
branches:
- main
tags:
- "[0-9]*"
paths:
- docs/**
- boards.txt
- mkdocs.yml
- requirements-docs.txt
- .github/workflows/publish-docs.yml
workflow_dispatch:
permissions:
contents: read
concurrency:
group: publish-root-docs
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- run: python -m pip install -r requirements-docs.txt
- name: Configure Git author
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- uses: actions/create-github-app-token@v1
id: pages-token
with:
app-id: ${{ secrets.DOCS_PUBLISH_APP_ID }}
private-key: ${{ secrets.DOCS_PUBLISH_APP_PRIVATE_KEY }}
owner: stm32duino
repositories: stm32duino.github.io
permission-contents: write
- name: Configure Pages remote
env:
PAGES_TOKEN: ${{ steps.pages-token.outputs.token }}
run: git remote add pages "https://x-access-token:${PAGES_TOKEN}@github.com/stm32duino/stm32duino.github.io.git"
- name: Fetch published documentation
run: |
if git ls-remote --exit-code --heads pages gh-pages >/dev/null; then
git fetch pages gh-pages
fi
- name: Publish development documentation
if: github.ref == 'refs/heads/main'
run: |
if git ls-remote --exit-code --heads pages gh-pages >/dev/null; then
mike deploy --remote pages --branch gh-pages --push dev
else
mike deploy --remote pages --branch gh-pages --push dev
mike set-default --remote pages --branch gh-pages --push dev
fi
- name: Publish release documentation
if: startsWith(github.ref, 'refs/tags/')
env:
VERSION: ${{ github.ref_name }}
run: |
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Unsupported documentation release tag: $VERSION" >&2
exit 1
fi
latest=$(git tag --list | grep -E '^[0-9]{1,3}\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)
if [[ "$VERSION" == "$latest" ]]; then
mike deploy --remote pages --branch gh-pages --update-aliases --push "$VERSION" latest
mike set-default --remote pages --branch gh-pages --push latest
else
mike deploy --remote pages --branch gh-pages --push "$VERSION"
fi