-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreadme-github-pages.sh
executable file
·149 lines (120 loc) · 4.74 KB
/
readme-github-pages.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
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
#!/bin/sh
# crypto-wallet-status readme-github-pages.sh
echo " "
if [ "$1" = "-debug" ]
then
echo "readme-github-pages.sh -debug (START)"
# set -e causes the shell to exit if any subcommand or pipeline returns a non-zero status. Needed for concourse.
# set -x enables a mode of the shell where all executed commands are printed to the terminal.
set -e -x
echo " "
else
echo "readme-github-pages.sh (START)"
# set -e causes the shell to exit if any subcommand or pipeline returns a non-zero status. Needed for concourse.
set -e
echo " "
fi
echo "GOAL ----------------------------------------------------------------------------------"
echo " "
echo "The goal is to git clone /crypto-wallet-status to /crypto-wallet-status-updated"
echo "Then script will edit the /docs/_includes/README.md for GITHUB WEBPAGES"
echo "Finally push the changes in /docs/_includes/README.md to github"
echo " "
echo "CHECK THINGS --------------------------------------------------------------------------"
echo " "
echo "At start, you should be in a /tmp/build/xxxxx directory with two folders:"
echo " /crypto-wallet-status"
echo " /crypto-wallet-status-updated (created in task-build-push.yml task file)"
echo " "
echo "pwd is: $PWD"
echo " "
echo "List whats in the current directory"
ls -la
echo " "
echo "GIT CLONE -----------------------------------------------------------------------------"
echo " "
echo "git clone crypto-wallet-status to crypto-wallet-status-updated"
git clone crypto-wallet-status crypto-wallet-status-updated
echo " "
echo "cd crypto-wallet-status-updated"
cd crypto-wallet-status-updated
echo " "
echo "List whats in the current directory"
ls -la
echo " "
echo "EDIT README FOR GITHUB WEBPAGES -------------------------------------------------------"
echo " "
echo "Copy README.md to /docs/_includes/README.md and edit"
echo " Remove everything before the second heading in README.md. Place in temp-README.md"
echo " sed '0,/GitHub Webpage/d' README.md > temp-README.md"
sed '0,/GitHub Webpage/d' README.md > temp-README.md
echo " Change the first heading ## to #"
echo " sed -i '0,/##/{s/##/#/}' temp-README.md"
sed -i '0,/##/{s/##/#/}' temp-README.md
echo " Update the image links (remove docs/)"
echo " sed -i 's#IMAGE](docs/#IMAGE](#g' temp-README.md"
sed -i 's#IMAGE](docs/#IMAGE](#g' temp-README.md
echo " Update the image links for svgs (if you have them)"
echo " Add \"https://raw.githubusercontent.com/JeffDeCola/REPONAME/master/svgs/\" to \"svgs/\""
echo " sed -i 's/svgs\//https:\/\/raw.githubusercontent.com\/JeffDeCola\/crypto-wallet-status\/master\/svgs\//g' temp-README.md"
sed -i 's/svgs\//https:\/\/raw.githubusercontent.com\/JeffDeCola\/crypto-wallet-status\/master\/svgs\//g' temp-README.md
echo " "
echo "GIT COMMIT OR NOT ---------------------------------------------------------------------"
echo " "
commit="yes"
echo "Does docs/_includes/README.md exist?"
if test -f docs/_includes/README.md
then
echo " Yes, it exists."
# CHECK IF THERE IS A DIFF
if (cmp -s temp-README.md docs/_includes/README.md)
then
commit="no"
echo " No changes are needed, Do not need to git commit and push"
else
echo " Updates are needed"
fi
echo " "
else
echo " No, it does not exist"
echo " Creating the _includes directory if it doesn't exist"
mkdir -p docs/_includes
echo " "
fi
if [ "$commit" = "yes" ]
then
echo "GIT SETUP -------------------------------------------------------------------------"
echo " "
echo "cp temp-README.md docs/_includes/README.md"
cp temp-README.md docs/_includes/README.md
echo " "
echo "Update some global git variables"
echo "git config --global user.email \"jeffdecola@gmail.com\""
echo "git config --global user.name \"Jeff DeCola (Concourse)\""
git config --global user.email "jeffdecola@gmail.com"
git config --global user.name "Jeff DeCola (Concourse)"
echo " "
git config --list
echo " "
echo "GIT PUSH MASTER BRANCH ------------------------------------------------------------"
echo " "
echo "git add and commit what is needed to protect from unforseen issues"
echo "git add docs/_includes/README.md"
git add docs/_includes/README.md
echo " "
echo " git commit -m \"Update docs/_includes/README.md for GitHub WebPage\""
git commit -m "Update docs/_includes/README.md for GitHub WebPage"
echo " "
echo "git status"
git status
echo " "
echo "git push - Not needed here since its done in pipeline"
echo " "
fi
echo "CLEAN UP ------------------------------------------------------------------------------"
echo " "
echo "rm temp-README.md"
rm temp-README.md
echo " "
echo "readme-github-pages.sh (END)"
echo " "