Skip to content

Commit 8aa881e

Browse files
committed
Initial code
1 parent cf9594a commit 8aa881e

File tree

7 files changed

+412
-0
lines changed

7 files changed

+412
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.out

generateCIVariables.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# TODO (workflows) - Trigger CI build:
2+
# 1. clone random repo from list (/dev/urandom) select line=(rnd num % (len of list - 1)) + 1 --> using number $ head -$line $file | tail -1
3+
# 2. replace tmpl files with random color from list (/dev/urandom)
4+
# 3. replace commits.tmpl and select random commit message (/dev/urandom)
5+
# 4. commit changes
6+
7+
# TODO (workflows) - Trigger CD build:
8+
# 1. workflow to wait for multiple webhooks to be true to proceed with trio app deployment pipeline
9+
10+
# Execute relative to the script path
11+
cd "$(dirname "$0")"
12+
13+
REPLACEMENTS_FILE=./res/colors.list
14+
COMMITS_FILE=./res/commits.tmpl
15+
REPOS_FILE=./res/repos.list
16+
17+
function getLine() {
18+
local input_file=$1
19+
local random=$(od -vAn -N2 -tu2 < /dev/urandom |tr -d ' ');
20+
# wc counts newlines, not lines. Each file should has a trialing new lines so modulo arithmetic will work correctly
21+
local number_of_lines=$(wc -l < ${input_file} | tr -d ' ')
22+
# Head read line starting at 1 not 0, so we add 1 to the result
23+
local selected_line=$(( ${random} % ${number_of_lines} + 1 ))
24+
local result=$(head -n${selected_line} ${input_file} | tail -n1)
25+
printf "${result}"
26+
}
27+
28+
function splitRepoInfo() {
29+
local repo_arr=(${1})
30+
# Set globals
31+
REPO=${repo_arr[0]}
32+
BRANCH=${repo_arr[1]}
33+
TEMPLATE_PATH=${repo_arr[2]}
34+
OUTPUT_PATH=${repo_arr[3]}
35+
SEARCH_STRING=${repo_arr[4]}
36+
}
37+
38+
# Text to replace search string with if found in files
39+
REPLACEMENT_TEXT=$(getLine ${REPLACEMENTS_FILE})
40+
41+
# Repo, branch, file and search string in file to clone and replace
42+
# Quotes preserve spaces we are passing
43+
REPO_INFO=$(getLine ${REPOS_FILE})
44+
splitRepoInfo "${REPO_INFO}"
45+
46+
# Commit message to set for committing files changs
47+
COMMIT=$(getLine ${COMMITS_FILE} | sed "s/${SEARCH_STRING}/${REPLACEMENT_TEXT}/g")
48+
49+
50+
# Could also output JSON and parse it with sprig templates in workflows
51+
echo "Outputting info:"
52+
echo "Repo info: ${REPO_INFO}"
53+
echo "Commit: ${COMMIT}"
54+
echo "Replacement text: ${REPLACEMENT_TEXT}"
55+
# Output values to files to be read as outputs
56+
printf "${REPO}" > target_repo.out
57+
printf "${BRANCH}" > target_branch.out
58+
printf "${TEMPLATE_PATH}" > target_template_filepath.out
59+
printf "${OUTPUT_PATH}" > target_putput_filepath.out
60+
printf "${SEARCH_STRING}" > target_search_string.out
61+
printf "${REPLACEMENT_TEXT}" > target_replacement.out
62+
printf "${COMMIT}" > target_commit_message.out

res/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Res
2+
Resources for use with script
3+
4+
## Format
5+
Each file has a trailing newline to make WC count correctly
6+
7+
### colors.list
8+
Line format: `color`
9+
### commits.tmpl
10+
Line format: `commit_message`
11+
### repos.list
12+
Line format: `repo branch template_filepath output_filepath search_string`
13+

res/colors.list

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
AliceBlue
2+
AntiqueWhite
3+
Aqua
4+
Aquamarine
5+
Azure
6+
Beige
7+
Bisque
8+
Black
9+
BlanchedAlmond
10+
Blue
11+
BlueViolet
12+
Brown
13+
BurlyWood
14+
CadetBlue
15+
Chartreuse
16+
Chocolate
17+
Coral
18+
CornflowerBlue
19+
Cornsilk
20+
Crimson
21+
Cyan
22+
DarkBlue
23+
DarkCyan
24+
DarkGoldenRod
25+
DarkGray
26+
DarkGrey
27+
DarkGreen
28+
DarkKhaki
29+
DarkMagenta
30+
DarkOliveGreen
31+
DarkOrange
32+
DarkOrchid
33+
DarkRed
34+
DarkSalmon
35+
DarkSeaGreen
36+
DarkSlateBlue
37+
DarkSlateGray
38+
DarkSlateGrey
39+
DarkTurquoise
40+
DarkViolet
41+
DeepPink
42+
DeepSkyBlue
43+
DimGray
44+
DimGrey
45+
DodgerBlue
46+
FireBrick
47+
FloralWhite
48+
ForestGreen
49+
Fuchsia
50+
Gainsboro
51+
GhostWhite
52+
Gold
53+
GoldenRod
54+
Gray
55+
Grey
56+
Green
57+
GreenYellow
58+
HoneyDew
59+
HotPink
60+
IndianRed
61+
Indigo
62+
Ivory
63+
Khaki
64+
Lavender
65+
LavenderBlush
66+
LawnGreen
67+
LemonChiffon
68+
LightBlue
69+
LightCoral
70+
LightCyan
71+
LightGoldenRodYellow
72+
LightGray
73+
LightGrey
74+
LightGreen
75+
LightPink
76+
LightSalmon
77+
LightSeaGreen
78+
LightSkyBlue
79+
LightSlateGray
80+
LightSlateGrey
81+
LightSteelBlue
82+
LightYellow
83+
Lime
84+
LimeGreen
85+
Linen
86+
Magenta
87+
Maroon
88+
MediumAquaMarine
89+
MediumBlue
90+
MediumOrchid
91+
MediumPurple
92+
MediumSeaGreen
93+
MediumSlateBlue
94+
MediumSpringGreen
95+
MediumTurquoise
96+
MediumVioletRed
97+
MidnightBlue
98+
MintCream
99+
MistyRose
100+
Moccasin
101+
NavajoWhite
102+
Navy
103+
OldLace
104+
Olive
105+
OliveDrab
106+
Orange
107+
OrangeRed
108+
Orchid
109+
PaleGoldenRod
110+
PaleGreen
111+
PaleTurquoise
112+
PaleVioletRed
113+
PapayaWhip
114+
PeachPuff
115+
Peru
116+
Pink
117+
Plum
118+
PowderBlue
119+
Purple
120+
RebeccaPurple
121+
Red
122+
RosyBrown
123+
RoyalBlue
124+
SaddleBrown
125+
Salmon
126+
SandyBrown
127+
SeaGreen
128+
SeaShell
129+
Sienna
130+
Silver
131+
SkyBlue
132+
SlateBlue
133+
SlateGray
134+
SlateGrey
135+
Snow
136+
SpringGreen
137+
SteelBlue
138+
Tan
139+
Teal
140+
Thistle
141+
Tomato
142+
Turquoise
143+
Violet
144+
Wheat
145+
White
146+
WhiteSmoke
147+
Yellow
148+
YellowGreen

res/commits.tmpl

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
KPT-11: Format the Readme sections
2+
KPT-13: Set env vars in Dockerfile for more modularity
3+
KPT-17: Remove unused env vars from Dockerfile
4+
KPT-22: Modals with REPLACEME accent color
5+
KPT-23: Update button CSS to round off corners
6+
KPT-24: Update background color to REPLACEME
7+
KPT-25: Refactor code
8+
KPT-26: New backend route for userinfo
9+
KPT-27: Update and test libraries
10+
KPT-28: Surprise and delight
11+
KPT-29: Split content to new pages

res/repos.list

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
https://github.com/codefresh-contrib/express-microservice2.git develop /public/stylesheets/style.tmpl /public/stylesheets/style.css REPLACEME
2+
https://github.com/codefresh-contrib/example-multiservice2.git feat/ctrlr-updates /ctrlr/flaskr/static/style.tmpl /ctrlr/flaskr/static/style.css REPLACEME
3+
https://github.com/codefresh-contrib/example-multiservice2.git feat/flaskr-ui-refresh /flask-ui/flaskr/static/style.tmpl /flask-ui/flaskr/static/style.css REPLACEME
4+
https://github.com/codefresh-contrib/example-multiservice2.git fix/buslog-critical-bug /buslog/flaskr/static/style.tmpl /buslog/flaskr/static/style.css REPLACEME

0 commit comments

Comments
 (0)