-
Notifications
You must be signed in to change notification settings - Fork 1.4k
169 lines (157 loc) · 6.57 KB
/
build_doc.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
name: Documentation
on:
issue_comment:
types: [created]
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
build:
permissions:
contents: read # to fetch code (actions/checkout)
pull-requests: write # to create comment
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
id: get_round
with:
result-encoding: string
script: |
const asso = context.payload.comment.author_association
if(asso == 'OWNER' || asso == 'MEMBER') {
const body = context.payload.comment.body
if(body.includes("build:")) {
const re = /\/(force-)?build:(\w+)\s*/;
if(re.test(body)){
const res = re.exec(body)
if(body.includes("force-")) {
return res[2]+":yes"
}
else{
return res[2]+":no"
}
}
}
}
return 'stop'
- uses: actions/github-script@v7
if: steps.get_round.outputs.result != 'stop'
id: get_pr_number
with:
result-encoding: string
script: |
//get pullrequest url
const pr_number = context.payload.issue.number
return pr_number
- name: Emoji-comment
uses: actions/github-script@v7
if: steps.get_round.outputs.result != 'stop'
with:
script: |
github.rest.reactions.createForIssueComment({
comment_id: ${{ github.event.comment.id }},
owner: context.repo.owner,
repo: context.repo.repo,
content: 'rocket'
})
- uses: actions/checkout@v4
name: "checkout branch"
if: steps.get_round.outputs.result != 'stop'
with:
repository: ${{ github.repository }}
ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge
fetch-depth: 2
- name: install dependencies
if: steps.get_round.outputs.result != 'stop'
run: |
set -x
sudo apt-get update && sudo apt-get install -y graphviz ssh bibtex2html
sudo pip install lxml
sudo pip install pyquery
wget --no-verbose -O doxygen_exe https://cgal.geometryfactory.com/~cgaltest/doxygen_1_9_6_patched/doxygen
sudo mv doxygen_exe /usr/bin/doxygen
sudo chmod +x /usr/bin/doxygen
git config --global user.email "[email protected]"
git config --global user.name "cgaltest"
- name: configure all
if: steps.get_round.outputs.result != 'stop'
run: |
set -ex
mkdir -p build_doc && cd build_doc && cmake ../Documentation/doc
- name: Build and Upload Doc
id: build_and_run
if: steps.get_round.outputs.result != 'stop'
run: |
set -ex
PR_NUMBER=${{ steps.get_pr_number.outputs.result }}
TMP_ROUND=${{ steps.get_round.outputs.result }}
ROUND=$(echo $TMP_ROUND | cut -d ":" -f 1)
force=$(echo $TMP_ROUND | cut -d ":" -f 2)
wget --no-verbose cgal.github.io -O tmp.html
if ! egrep -q "\/$PR_NUMBER\/$ROUND" tmp.html || [ "$force" = "yes" ]; then
#list impacted packages
LIST_OF_PKGS=$(git diff --name-only HEAD^1 HEAD |cut -s -d/ -f1 |sort -u | xargs -I {} echo {} && ls -d {}/package_info 2>/dev/null |cut -d/ -f1 |egrep -v Installation||true)
if [ "$LIST_OF_PKGS" = "" ]; then
echo "DoxygenError=No package affected." >> $GITHUB_OUTPUT
exit 1
fi
cd build_doc && make -j$(nproc) doc
make -j$(nproc) doc_with_postprocessing 2>tmp.log
if [ -s tmp.log ]; then
content=`cat ./tmp.log`
delimiter="$(openssl rand -hex 8)"
echo "DoxygenError<<${delimiter}" >> "${GITHUB_OUTPUT}"
cat tmp.log >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
exit 1
fi
cd ..
git clone https://CGAL:${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}@github.com/CGAL/cgal.github.io.git
mkdir -p cgal.github.io/${PR_NUMBER}/$ROUND
rm cgal.github.io/${PR_NUMBER}/$ROUND/* -rf
for f in $LIST_OF_PKGS
do
if [ -d ./build_doc/doc_output/$f ]; then
cp -r ./build_doc/doc_output/$f ./cgal.github.io/${PR_NUMBER}/$ROUND
fi
done
cp -r ./build_doc/doc_output/Manual ./cgal.github.io/${PR_NUMBER}/$ROUND
cd ./cgal.github.io
egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true
echo "<li><a href=https://cgal.github.io/${PR_NUMBER}/$ROUND/Manual/index.html>Manual for PR ${PR_NUMBER} ($ROUND).</a></li>" >> ./tmp.html
mv tmp.html index.html
git add ${PR_NUMBER}/$ROUND index.html && git commit -q --amend -m "base commit" && git push -q -f -u origin master
else
echo "DoxygenError=This round already exists. Overwrite it with /force-build." >> $GITHUB_OUTPUT
exit 1
fi
- name: Post address
uses: actions/github-script@v7
if: ${{ success() && steps.get_round.outputs.result != 'stop' }}
with:
script: |
const tmp_round = "${{ steps.get_round.outputs.result }}";
const id = tmp_round.indexOf(":");
const round = tmp_round.substring(0,id);
const address = "The documentation is built. It will be available, after a few minutes, here: https://cgal.github.io/${{ steps.get_pr_number.outputs.result }}/"+round+"/Manual/index.html"
github.rest.issues.createComment({
owner: "CGAL",
repo: "cgal",
issue_number: ${{ github.event.issue.number }},
body: address
});
- name: Post error
env:
ERRORMSG: ${{steps.build_and_run.outputs.DoxygenError}}
uses: actions/github-script@v7
if: ${{ failure() && steps.get_round.outputs.result != 'stop' }}
with:
script: |
const error = process.env.ERRORMSG
const job_url = `${context.serverUrl}/CGAL/cgal/actions/runs/${context.runId}`
const msg = "There was an error while building the doc: \n```\n"+error + "\n```\n" + job_url
github.rest.issues.createComment({
owner: "CGAL",
repo: "cgal",
issue_number: ${{ github.event.issue.number }},
body: msg
});