forked from ariordan-redhat/preview-pr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
preview-pr.sh
executable file
·57 lines (55 loc) · 1.59 KB
/
preview-pr.sh
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
#!/bin/bash
#
# This script loads a HTML preview of a book to the aap-builds repo
#
# To operate this script, run the following command from the /titles directory in your AAP docs repo:
# preview-pr.sh <PR-number>
#
# Example command:
# preview-pr 801
#
###########################################################
#
aapbuildsurl=https://gmurray-redhat.github.io/aap-builds
aapbuildspath=/gmurray/repos/aap-builds
sourcebranch=$(git symbolic-ref --short HEAD)
sourcepath=$(pwd)
sourcedir=$(basename $sourcepath)
sourcefile=$(ls -d -1 $sourcepath/master.html)
builddate=$(date -I)
### branch=($1)
targetfile=$(echo "$sourcedir-$sourcebranch-$builddate.html")
targetpath=$(echo "$aapbuildspath/docs/$targetfile")
targetreadme=$(echo "$aapbuildspath/README.md")
targeturl=$(echo "$aapbuildsurl/$targetfile")
commitmessage=$(echo "$targeturl")
echo "The aap-builds repo is located here: $aapbuildspath"
echo "Path to directory is $sourcepath"
echo "Directory name is $sourcedir"
echo "Date is $builddate"
echo "targetfile is $targetfile"
echo "targetpath is $targetpath"
echo "Commit message is $commitmessage"
echo "sourcefile is $sourcefile"
echo "Target URL is $targeturl"
echo "###"
# Copy the built doc to your local aap-builds repo
cp master.html $targetpath
ls -t $targetpath
pushd $aapbuildspath
echo "$targeturl" >> $targetreadme
git status
git add $targetpath
git add $targetreadme
git status
git commit -m "$commitmessage"
git log --oneline -n 2
git push origin HEAD
popd
# List all master.adoc files
# clean up temporary files
## rm tmp.docx
## rm atree-output.docx
## rm used-modules.docx
## rm all-modules.docx
# rm *.bak