Repository navigation
103 lines (99 loc) · 3.54 KB
/
Copy pathpublish-docs.yml
File metadata and controls
103 lines (99 loc) · 3.54 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
name: Publish versioned core documentation
on:
push:
branches:
- main
tags:
- "[0-9]*"
paths:
- docs/**
- boards.txt
- mkdocs.yml
- requirements-docs.txt
- doxygen/**
- cores/**
- libraries/**
- variants/**
- system/**
- "!system/Drivers/**"
- "!system/Middlewares/**"
- .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@v7
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: "3.x"
- run: python -m pip install -r requirements-docs.txt
- name: Install Doxygen
run: sudo apt-get update && sudo apt-get install --yes doxygen
- name: Build Doxygen API reference
run: |
STM32_CORE_VERSION=$(sed -n 's/^version=//p' platform.txt)
export STM32_CORE_VERSION
doxygen doxygen/Doxyfile
test -f build/doxygen/index.html
- 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@v3
id: pages-token
with:
client-id: ${{ vars.DOCS_PUBLISH_APP_CLIENT_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: |
# Core releases have a major version below 1000: this excludes the
# legacy date tags such as 2018.1.18, which would otherwise sort last.
if [[ ! "$VERSION" =~ ^[0-9]{1,3}\.[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 git ls-remote --exit-code --heads pages gh-pages >/dev/null; then
git fetch pages gh-pages:gh-pages
fi
if [[ "$VERSION" == "$latest" ]]; then
mike deploy --branch gh-pages --update-aliases "$VERSION" latest
mike set-default --branch gh-pages latest
else
mike deploy --branch gh-pages "$VERSION"
fi
# One push so GitHub Pages builds the site once.
git push pages gh-pages