-
Notifications
You must be signed in to change notification settings - Fork 6
141 lines (122 loc) · 3.66 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
# Copyright 2022 Tim Duesterhus <tim@bastelstu.be>
#
# 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.9 2.8 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@v4
with:
fetch-depth: 0
- name: Prepare git.
run: |
git config --global user.name "HAProxy Community"
git config --global user.email "haproxy@formilux.org"
git config --global gc.autoDetach "false"
- name: Install Python.
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Clone dconv.
uses: actions/checkout@v4
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@v4
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
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/"
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
- name: Push the changes.
run: |
git push