-
Notifications
You must be signed in to change notification settings - Fork 20
77 lines (63 loc) · 2.28 KB
/
release_docs.yml
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
name: Release Docs
on:
push:
tags:
- 'v*' # Triggers on any tag push or force-push
workflow_dispatch: # Allows manual trigger
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Cache Dependencies
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- name: Restore Cached Dependencies
uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- name: Install mkdocs-material and mike
run: |
python -m pip install --upgrade pip
pip install --disable-pip-version-check -r requirements.txt
- name: Extract version from tag
run: |
TAG_NAME=$(git tag --list "v*" --sort=-version:refname | head -n 1)
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
echo "Extracted TAG_NAME: ${TAG_NAME}"
- name: Deploy Docs
run: |
git fetch origin gh-pages
git checkout gh-pages
git pull origin gh-pages --rebase
git checkout "$TAG_NAME"
mike deploy "$TAG_NAME" --push
mike set-default "$TAG_NAME" --push
- name: Create or Update Tag-Based Branch
run: |
# Define the branch name from the tag
BRANCH_NAME="release-${TAG_NAME}"
# Check if the branch exists
if git ls-remote --heads origin "$BRANCH_NAME" | grep "$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME exists, updating..."
git checkout "$BRANCH_NAME"
git reset --hard "$TAG_NAME"
else
echo "Branch $BRANCH_NAME does not exist, creating..."
git checkout -b "$BRANCH_NAME" "$TAG_NAME"
fi
# Push the branch forcefully to match the latest tag
git push origin "$BRANCH_NAME" --force