forked from ariordan-redhat/preview-pr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreview-pr.sh
More file actions
executable file
·68 lines (65 loc) · 2.17 KB
/
Copy pathpreview-pr.sh
File metadata and controls
executable file
·68 lines (65 loc) · 2.17 KB
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
#!/bin/bash
#
# This script loads a HTML preview of a book to the aap-builds repo
#
# PREREQUISITE 1: Create an aap-builds repo in your github instance.
# You can fork Aine's copy from https://github.com/ariordan-redhat/aap-builds if you like,
# then clone your fork using the following command:
# git clone https://github.com/<your_github_id>/aap-builds
#
# PREREQUISITE 2:
# Modify the aapbuildsurl and aapbuildspath in the script - these are labelled PREREQUISITE.
#
# PREREQUISITE 3:
# Build a doc using asciidoctor.
# that you have added the images to your aap-builds repo if you need them.
#
# To operate this script, run the following command from the downstream/titles/title-name directory
# in your AAP docs repo (for example, downstream/titles/aap-installation-guide):
# preview-pr.sh
#
# Example command:
# preview-pr
#
# The script copies master.html
#
###########################################################
#
# PREREQUISITE: Configure the URL for your aap-builds repo
aapbuildsurl=https://jonquilwilliams.github.io/aap-builds
# PREREQUISITE: Configure the path to your local copy of aap-builds repo
aapbuildspath=/Users/jonwilli/repos/aap-builds
#
sourcebranch=$(git symbolic-ref --short HEAD)
sourcepath=$(pwd)
sourcedir=$(basename $sourcepath)
sourcefile=$(ls -d -1 $sourcepath/master.html)
builddate=$(date -I)
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