mirror of https://github.com/CGAL/cgal
145 lines
5.7 KiB
YAML
145 lines
5.7 KiB
YAML
name: Documentation
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
jobs:
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/github-script@v3
|
|
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@v3
|
|
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
|
|
- uses: actions/checkout@v2
|
|
name: "checkout branch"
|
|
if: steps.get_round.outputs.result != 'stop'
|
|
with:
|
|
repository: ${{ github.repository }}
|
|
ref: refs/pull/${{ steps.get_pr_number.outputs.result }}/merge
|
|
token: ${{ secrets.PUSH_TO_CGAL_GITHUB_IO_TOKEN }}
|
|
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==1.4.1' # it seems to be the last py2 compatible version
|
|
wget --no-verbose -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen/build_1_8_13/bin/doxygen
|
|
sudo mv doxygen_exe /usr/bin/doxygen
|
|
sudo chmod +x /usr/bin/doxygen
|
|
git config --global user.email "maxime.gimeno@geometryfactory.com"
|
|
git config --global user.name "Maxime Gimeno"
|
|
|
|
- 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 "::set-output name=DoxygenError::No package affected."
|
|
exit 1
|
|
fi
|
|
cd build_doc && make -j2 doc
|
|
make -j2 doc_with_postprocessing 2>tmp.log
|
|
if [ -s tmp.log ]; then
|
|
content=`cat ./tmp.log`
|
|
echo "::set-output name=DoxygenError::$(cat tmp.log)"
|
|
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
|
|
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 "::set-output name=DoxygenError::This round already exists. Overwrite it with /force-build"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Post address
|
|
uses: actions/github-script@v3
|
|
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.issues.createComment({
|
|
owner: "CGAL",
|
|
repo: "cgal",
|
|
issue_number: ${{ github.event.issue.number }},
|
|
body: address
|
|
});
|
|
|
|
- name: Post error
|
|
uses: actions/github-script@v3
|
|
if: ${{ failure() && steps.get_round.outputs.result != 'stop' }}
|
|
with:
|
|
script: |
|
|
const error = "${{steps.build_and_run.outputs.DoxygenError}}"
|
|
const msg = "There was an error while building the doc: \n"+error
|
|
github.issues.createComment({
|
|
owner: "CGAL",
|
|
repo: "cgal",
|
|
issue_number: ${{ github.event.issue.number }},
|
|
body: msg
|
|
});
|