-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (152 loc) · 5.89 KB
/
deploy-docs.yml
File metadata and controls
169 lines (152 loc) · 5.89 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Build and Deploy MkDocs Versions with Mike
on:
push:
branches:
- 'cells-v4'
- 'cells-v5'
- 'pydio-v8'
#- 'main' # sync workflow file
jobs:
sync-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout pydio/docs (pushed branch)
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Debug workflow trigger
run: |
echo "Event: ${{ github.event_name }}"
echo "Branch: ${{ github.ref_name }}"
echo "Repository: ${{ github.repository }}"
- name: Checkout main for config and resources
uses: actions/checkout@v4
with:
ref: main
path: main-config
- name: Sync workflow file to cells-v4 and cells-v5
if: github.ref_name == 'main' && contains(github.event.commits.*.added, '.github/workflows/build-docs.yaml') || contains(github.event.commits.*.modified, '.github/workflows/build-docs.yaml')
run: |
git config user.name "GitHub Action"
git config user.email "action@github.com"
for branch in cells-v4 cells-v5 pydio-v8; do
git checkout $branch || git checkout -b $branch
mkdir -p .github/workflows
cp .github/workflows/build-docs.yaml .github/workflows/
git add .github/workflows/build-docs.yaml
git commit -m "Sync build-docs.yaml from main to $branch" || echo "No changes to commit"
git push origin $branch
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Copy config and resources from main
run: |
cp main-config/mkdocs.yml .
cp main-config/requirements.txt .
mkdir -p resources docs/assets overrides
cp main-config/resources/* resources/ || echo "resources not found"
cp main-config/docs/assets/custom.css docs/assets/ || echo "custom.css not found"
cp main-config/overrides/404.html overrides/ || echo "404.html not found"
cp -r main-config/tools .
rm -rf main-config
- name: Copy docs to docs repo
run: |
cp -r admin-guide docs
cp -r cellsflows docs
cp -r developer-guide docs
cp -r knowledge-base docs
cp resources/pydio-favicon.png docs
- name: Debug contents
run: |
ls -la .
ls -la docs/ || echo "docs/ not found"
ls -la resources/ || echo "resources/ not found"
ls -la docs/assets/ || echo "docs/assets/ not found"
ls -la overrides/ || echo "overrides/ not found"
cat docs/index.md || echo "index.md not readable"
cat resources/fix_index.html || echo "fix_index.html not readable"
cat docs/cellsflows/1_preset_flows/1_efficient-system-maintenance/0_backup-personal-files.md || echo "File not readable"
- name: Initialize gh-pages if not exists
run: |
git fetch origin gh-pages || {
echo "gh-pages does not exist, creating it"
git checkout --orphan gh-pages
git rm -rf .
echo "# Pydio Docs" > README.md
git add README.md
git config user.name "GitHub Action"
git config user.email "action@github.com"
git commit -m "Initialize gh-pages branch"
git push origin gh-pages
git checkout ${{ github.ref_name }}
}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Generate tocs
run: |
./tools/gen_toplevel_section_toc.sh docs
./tools/gen_sub_section_toc.sh docs
- name: Validate MkDocs build
run: |
mkdocs build --verbose
ls -la site/
- name: Deploy with mike
run: |
git config user.name "GitHub Action"
git config user.email "action@github.com"
VERSION=${GITHUB_REF_NAME}
ALIAS=""
if [ "$VERSION" = "cells-v4" ]; then
ALIAS="latest"
fi
echo "Deploying $VERSION with alias $ALIAS"
mike deploy --push "$VERSION" $ALIAS 2>&1 | tee mike_deploy.log
if [ $? -ne 0 ]; then
cat mike_deploy.log
echo "mike deploy failed"
exit 1
fi
if [ "$VERSION" = "cells-v4" ]; then
echo "Setting default to cells-v4"
mike set-default --push cells-v4 2>&1 | tee mike_default.log
if [ $? -ne 0 ]; then
cat mike_default.log
echo "mike set-default failed"
exit 1
fi
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Debug contents after mike build
run: |
ls -la .
ls -lah resources
- name: Copy custom files to gh-pages
run: |
git config user.name "GitHub Action"
git config user.email "action@github.com"
git fetch origin gh-pages
git checkout gh-pages
VERSION=${GITHUB_REF_NAME}
mkdir -p "$VERSION"
cp resources/fix_index.html "$VERSION/index.html" || echo "fix_index.html not found"
cp resources/versions.json versions.json || echo "versions.json not found"
git add "$VERSION/index.html" versions.json
git commit -m "Add custom index and versions.json for $VERSION" || echo "No changes to commit"
git push origin gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}