fix daily builder failure for parser prediction promise and attach to node master
[releng.git] / jjb / promise / docu-build.sh
1 #!/bin/bash
2 set -e
3 set -o pipefail
4 project="$(git remote -v | head -n1 | awk '{{print $2}}' | sed -e 's,.*:\(.*/\)\?,,' -e 's/\.git$//')"
5 export PATH=$PATH:/usr/local/bin/
6
7 git_sha1="$(git rev-parse HEAD)"
8 docu_build_date="$(date)"
9
10 files=()
11 while read -r -d ''; do
12         files+=("$REPLY")
13 done < <(find * -type f -iname '*.rst' -print0)
14
15 for file in "${{files[@]}}"; do
16
17         file_cut="${{file%.*}}"
18         gs_cp_folder="${{file_cut}}"
19
20         # sed part
21         sed -i "s/_sha1_/$git_sha1/g" $file
22         sed -i "s/_date_/$docu_build_date/g" $file
23
24         # rst2html part
25         echo "rst2html $file"
26         rst2html $file | gsutil cp -L gsoutput.txt - \
27         gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder".html
28         gsutil setmeta -h "Content-Type:text/html" \
29                         -h "Cache-Control:private, max-age=0, no-transform" \
30                         gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder".html
31         cat gsoutput.txt
32         rm -f gsoutput.txt
33
34         echo "rst2pdf $file"
35         rst2pdf $file -o - | gsutil cp -L gsoutput.txt - \
36         gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder".pdf
37         gsutil setmeta -h "Content-Type:application/pdf" \
38                         -h "Cache-Control:private, max-age=0, no-transform" \
39                         gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder".pdf
40         cat gsoutput.txt
41         rm -f gsoutput.txt
42
43 done
44
45 images=()
46 while read -r -d ''; do
47         images+=("$REPLY")
48 done < <(find * -type f \( -iname \*.jpg -o -iname \*.png \) -print0)
49
50 for img in "${{images[@]}}"; do
51
52         # uploading found images
53         echo "uploading $img"
54         cat "$img" | gsutil cp -L gsoutput.txt - \
55         gs://artifacts.opnfv.org/"$project"/"$img"
56         gsutil setmeta -h "Content-Type:image/jpeg" \
57                         -h "Cache-Control:private, max-age=0, no-transform" \
58                         gs://artifacts.opnfv.org/"$project"/"$img"
59         cat gsoutput.txt
60         rm -f gsoutput.txt
61
62 done