-
Notifications
You must be signed in to change notification settings - Fork 8
138 lines (117 loc) · 4.21 KB
/
doc_build.yml
File metadata and controls
138 lines (117 loc) · 4.21 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Documentation Build
permissions:
contents: read
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
paths:
- '.github/workflows/doc_build.yml'
- '**.rst'
- 'docs/**'
push:
branches:
- main
tags:
- v*
workflow_dispatch:
inputs:
publish_to_dev:
type: boolean
default: true
description: "Publish to dev (private) Zoomin"
publish_to_prod:
type: boolean
default: false
description: "Publish to prod (public) Zoomin"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.12
cache: pip
cache-dependency-path: docs/requirements.txt
pip-install: |
-r docs/requirements.txt
- name: Build
working-directory: docs
run: make html
- name: Check version
run: |
VERSION_REGEX="^v([0-9a-zA-Z\.\-]+)$"
if [[ ${GITHUB_REF#refs/tags/} =~ $VERSION_REGEX ]]; then
VERSION=${BASH_REMATCH[1]}
elif [[ ${GITHUB_REF#refs/heads/} == "main" ]]; then
VERSION="latest"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
VERSION="pr-${{ github.event.number }}"
fi
echo "VERSION=${VERSION}"
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
- name: Prepare Azure upload
run: |
PUBLISH="$PWD/publish"
mkdir -p "$PUBLISH"
MONITOR="monitor_${{ github.run_id }}.txt"
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
ARCHIVE="legacy-addon-aliro-pr-${{ github.event.number }}.zip"
echo "publish2 dev PR-${{ github.event.number }} ${ARCHIVE}" > "${MONITOR}"
echo "${{ github.event.number }}" > pr.txt
else
ARCHIVE="legacy-addon-aliro-${VERSION}.zip"
echo "publish2 main ${VERSION} ${ARCHIVE}" > "${MONITOR}"
fi
pushd "docs/build/html"
zip -rq "${ARCHIVE}" .
mv "${ARCHIVE}" "$PUBLISH"
popd
mv "${MONITOR}" "$PUBLISH"
if [[ -f pr.txt ]]; then mv pr.txt "$PUBLISH"; fi
- name: Prepare Zoomin upload
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
run: |
PUBLISH="$PWD/publish"
mkdir -p "$PUBLISH"
OUTDIR=docs/build/html
ARCHIVE="addon-aliro_$VERSION.zip"
cp docs/_zoomin/aliro.custom.properties "$OUTDIR/custom.properties"
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/custom.properties"
cp docs/_zoomin/aliro.tags.yml "$OUTDIR/tags.yml"
sed -i 's/__VERSION__/'"$VERSION"'/g' "$OUTDIR/tags.yml"
pushd "$OUTDIR"
zip -rq "$ARCHIVE" .
mv "$ARCHIVE" "$PUBLISH"
popd
- name: Save publish config
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
run: |
PUBLISH="$PWD/publish"
mkdir -p "$PUBLISH"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
PUBLISH_TO_DEV="${{ inputs.publish_to_dev }}"
PUBLISH_TO_PROD="${{ inputs.publish_to_prod }}"
else
PUBLISH_TO_DEV="true"
PUBLISH_TO_PROD="true"
fi
echo "publish_to_dev=$PUBLISH_TO_DEV" > "$PUBLISH/publish_config.txt"
echo "publish_to_prod=$PUBLISH_TO_PROD" >> "$PUBLISH/publish_config.txt"
- name: Store
if: ${{ !contains(github.event.pull_request.labels.*.name, 'external') || contains(github.event.pull_request.labels.*.name, 'CI-trusted-author') }}
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: docs
retention-days: 5
path: |
publish/*