|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - develop |
| 7 | + |
| 8 | + tags: |
| 9 | + - 'v*' |
| 10 | + |
7 | 11 | paths: |
8 | | - - 'docs/**/*' |
| 12 | + - 'docs/**' |
9 | 13 | - 'mkdocs.yml' |
10 | 14 | - '.github/workflows/docs.yml' |
11 | 15 |
|
12 | 16 | permissions: |
13 | 17 | contents: write |
14 | 18 |
|
| 19 | +concurrency: |
| 20 | + group: docs-deploy |
| 21 | + cancel-in-progress: false |
| 22 | + |
15 | 23 | jobs: |
16 | 24 | deploy: |
17 | 25 | runs-on: ubuntu-latest |
| 26 | + |
18 | 27 | steps: |
19 | | - - uses: actions/checkout@v6 |
20 | | - - uses: actions/setup-python@v6 |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v6 |
| 30 | + |
| 31 | + - name: Setup Python |
| 32 | + uses: actions/setup-python@v6 |
21 | 33 | with: |
22 | | - python-version: 3.x |
23 | | - - run: pip install mkdocs-material |
24 | | - - run: mkdocs gh-deploy --force |
| 34 | + python-version: '3.x' |
| 35 | + |
| 36 | + - name: Install dependencies |
| 37 | + run: pip install mkdocs-material mike |
| 38 | + |
| 39 | + - name: Fetch gh-pages |
| 40 | + run: git fetch origin gh-pages --depth=1 || true |
| 41 | + |
| 42 | + - name: Configure git |
| 43 | + run: | |
| 44 | + git config user.name github-actions[bot] |
| 45 | + git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
| 46 | +
|
| 47 | + - name: Deploy docs with mike |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + set -e |
| 51 | +
|
| 52 | + deploy_version () { |
| 53 | + local VERSION="$1" |
| 54 | + local UPDATE_LATEST="${2:-false}" |
| 55 | +
|
| 56 | + VERSION="${VERSION#v}" |
| 57 | +
|
| 58 | + MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/') |
| 59 | +
|
| 60 | + echo "Deploying docs version: $MINOR" |
| 61 | +
|
| 62 | + if [ "$UPDATE_LATEST" = "true" ]; then |
| 63 | + mike deploy --push --update-aliases "$MINOR" latest |
| 64 | + return |
| 65 | + fi |
| 66 | +
|
| 67 | + mike deploy --push "$MINOR" |
| 68 | + } |
| 69 | +
|
| 70 | + # |
| 71 | + # Develop branch |
| 72 | + # |
| 73 | + if [ "${{ github.ref_type }}" = "branch" ] && [ "${{ github.ref_name }}" = "develop" ]; then |
| 74 | + echo "Deploying dev docs" |
| 75 | +
|
| 76 | + mike deploy --push dev |
| 77 | +
|
| 78 | + exit 0 |
| 79 | + fi |
| 80 | +
|
| 81 | + # |
| 82 | + # Release tags |
| 83 | + # |
| 84 | + if [ "${{ github.ref_type }}" = "tag" ]; then |
| 85 | + VERSION="${{ github.ref_name }}" |
| 86 | +
|
| 87 | + if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 88 | + echo "Skipping non-stable release tag: $VERSION" |
| 89 | + exit 0 |
| 90 | + fi |
| 91 | +
|
| 92 | + deploy_version "$VERSION" true |
| 93 | +
|
| 94 | + echo "Setting default docs version: latest" |
| 95 | +
|
| 96 | + mike set-default --push latest |
| 97 | +
|
| 98 | + exit 0 |
| 99 | + fi |
| 100 | +
|
| 101 | + echo "Unsupported ref" |
| 102 | + exit 1 |
0 commit comments