-
-
Notifications
You must be signed in to change notification settings - Fork 12
118 lines (104 loc) · 3.46 KB
/
deploy-cobra-mkdocs-versioned-poetry.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/deploy-cobra-mkdocs-versioned-poetry.md
name: Deploy Website
on:
push:
branches:
# Branch to base "dev" website on. Set in siteversion.py also.
- main
# Release branches have names like 0.8.x, 0.9.x, ...
- "[0-9]+.[0-9]+.x"
paths:
- "docs/**"
- ".github/workflows/deploy-cobra-mkdocs-versioned-poetry.ya?ml"
- "**/.npmrc"
- "go.mod"
- "go.sum"
- "Taskfile.ya?ml"
- "**.go"
- "docsgen/**"
- "ruledocsgen/**"
- "mkdocs.ya?ml"
- "package.json"
- "package-lock.json"
- "poetry.lock"
- "pyproject.toml"
# Run on branch or tag creation (will be filtered by the publish-determination job).
create:
jobs:
publish-determination:
runs-on: ubuntu-latest
permissions: {}
outputs:
result: ${{ steps.determination.outputs.result }}
steps:
- name: Determine if documentation should be published on this workflow run
id: determination
run: |
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
if [[
"${{ github.event_name }}" == "push" ||
(
"${{ github.event_name }}" == "create" &&
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
)
]]; then
RESULT="true"
else
RESULT="false"
fi
echo "result=$RESULT" >> $GITHUB_OUTPUT
publish:
runs-on: ubuntu-latest
needs: publish-determination
if: needs.publish-determination.outputs.result == 'true'
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install Python
uses: actions/setup-python@v5
with:
python-version-file: pyproject.toml
- name: Install Poetry
run: |
python -m pip install --upgrade pip
python -m pip install poetry
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json
- name: Install Task
uses: arduino/setup-task@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x
- name: Create all generated documentation content
run: task docs:generate
- name: Install Python dependencies
run: poetry install --no-root
- name: Determine versioning parameters
id: determine-versioning
run: echo "data=$(poetry run python docs/siteversion/siteversion.py)" >> $GITHUB_OUTPUT
- name: Publish documentation
if: fromJson(steps.determine-versioning.outputs.data).version != null
run: |
# Publishing implies creating a git commit on the gh-pages branch, we let @ArduinoBot own these commits.
git config --global user.email "[email protected]"
git config --global user.name "ArduinoBot"
git fetch \
--no-tags \
--prune \
--depth=1 \
origin \
+refs/heads/gh-pages:refs/remotes/origin/gh-pages
poetry run mike deploy \
--update-aliases \
--push \
--remote origin \
${{ fromJson(steps.determine-versioning.outputs.data).version }} \
${{ fromJson(steps.determine-versioning.outputs.data).alias }}