-
Notifications
You must be signed in to change notification settings - Fork 6
169 lines (144 loc) · 4.63 KB
/
deploy.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
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
# Copyright 2022 Tim Duesterhus <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version
# 2 of the License, or (at your option) any later version.
name: Deploy
on:
push:
branches:
- master
paths:
- '.github/**'
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
permissions:
contents: write
jobs:
deploy:
concurrency:
group: target
cancel-in-progress: true
name: Deploy
runs-on: ubuntu-latest
env:
BRANCHES: "dev 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.9 1.8 1.7 1.6"
steps:
- name: Clone the docs.
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare git.
run: |
git config --global user.name "HAProxy Community"
git config --global user.email "[email protected]"
git config --global gc.autoDetach "false"
- name: Install Python.
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Clone dconv.
uses: actions/checkout@v3
with:
fetch-depth: 0
repository: cbonte/haproxy-dconv
path: dconv
- name: Install dconv dependencies.
run: |
pip3 install -r dconv/requirements.txt
- name: Download the HAProxy repository cache.
uses: actions/cache@v3
with:
path: |
haproxy/
key: haproxy-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
haproxy-
- name: Update the HAProxy repository.
run: |
set -x
if [ ! -d haproxy/.git ]; then
git clone https://github.com/haproxy/haproxy.git haproxy
fi
for branch in $BRANCHES; do
if [ "$branch" = "dev" ]; then
suffix=""
else
suffix="-$branch"
fi
if ! git -C haproxy remote |grep -q "haproxy$suffix"; then
git -C haproxy remote add "haproxy$suffix" "http://git.haproxy.org/git/haproxy$suffix.git/"
fi
done
for remote in $(git remote); do
if [ "$remote" != "origin" ]; then
found=
for branch in $BRANCHES; do
if [ "$branch" = "dev" ]; then
suffix=""
else
suffix="-$branch"
fi
if [ "$remote" = "haproxy$suffix" ]; then
found=1
fi
done
if [ -z "$found" ]; then
git -C haproxy remote rm "$remote"
fi
fi
done
git -C haproxy remote update --prune
- name: Rebuild the docs.
run: |
set -x
echo "User-agent: *" >/tmp/robot.txt
echo "Disallow:" >>/tmp/robot.txt
echo "Sitemap: https://docs.haproxy.org/sitemap.xml" >>/tmp/robot.txt
echo "<?xml version="1.0" encoding="UTF-8"?>" >/tmp/sitemap.xml
echo "<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">" >>/tmp/sitemap.xml
for branch in $BRANCHES; do
printf "::group::Building %s\n" "$branch"
if [ "$branch" = "dev" ]; then
suffix=""
else
suffix="-$branch"
fi
git -C haproxy checkout "haproxy$suffix/master"
files=(
"$PWD/haproxy/doc/intro.txt"
"$PWD/haproxy/doc/configuration.txt"
"$PWD/haproxy/doc/management.txt"
)
LASTCHANGE="$(git -C haproxy log -1 --pretty="%ct" -- ${files[@]})"
rm -rf "docs/$branch/"
mkdir "docs/$branch/"
for n in "${files[@]}"
do
file=$(basename $n)
file=${file%*.txt}.html
echo "<url><loc>https://docs.haproxy.org/${$branch}/${file}</loc></url>" >>/tmp/sitemap.xml
done
env SOURCE_DATE_EPOCH="$LASTCHANGE" python3 dconv/dconv.py -g "$PWD/haproxy/" -o "$PWD/docs/$branch/" --base=.. ${files[@]}
git add "docs/$branch/"
if ! git diff --cached --quiet; then
git commit -m "Update docs for $branch"
fi
printf "::endgroup::\n"
done
echo "</urlset>" >>/tmp/sitemap.xml
cp /tmp/sitemap.xml docs/sitemap.xml
git add "docs/sitemap.xml"
if ! git diff --cached --quiet; then
git commit -m "Update sitemap.xml"
fi
cp /tmp/robot.txt docs/robot.txt
git add "docs/robot.txt"
if ! git diff --cached --quiet; then
git commit -m "Update robot.txt"
fi
- name: Push the changes.
run: |
git push