@@ -25,63 +25,71 @@ ERRORS_FILE="$GITHUB_ACTION_PATH/data/codes.json"
2525CONFIG_FILE=" just.config.js"
2626CONFIG_DATA=" just.config.json"
2727
28- ErrorMessage () {
29- local ERROR_CODE=$1
30- local ERROR_MESSAGE=$( jq -r " .[\" run.sh\" ][] | select(.code==\" $ERROR_CODE \" ) | .message" " $ERRORS_FILE " )
31- local ERROR_LINK=$( jq -r ' .["run.sh"][] | select(.code=="0108") | .link' " $ERRORS_FILE " )
32- echo -e " \n\n\n\nError $ERROR_CODE : $ERROR_MESSAGE $ERROR_LINK "
33- }
28+ source $GITHUB_ACTION_PATH /src/modules/errmsg.sh
3429
3530if [ -f " $CONFIG_DATA " ]; then
36- local ERROR_MESSAGE=($( ErrorMessage " 0113" ) )
31+ local ERROR_MESSAGE=($( ErrorMessage " run.sh " " 0113" ) )
3732 echo $ERROR_MESSAGE && exit 1
3833fi
3934
4035if [ ! -f " $CONFIG_FILE " ]; then
41- ERROR_CODE=" 0108"
42- ERROR_MESSAGE=$( jq -r " .[\" run.sh\" ][] | select(.code==\" $ERROR_CODE \" ) | .message" " $ERRORS_FILE " )
43- ERROR_LINK=$( jq -r ' .["run.sh"][] | select(.code=="0108") | .link' " $ERRORS_FILE " )
44- echo " Error $ERROR_CODE : $ERROR_MESSAGE $ERROR_LINK "
45- exit 1
36+ local ERROR_MESSAGE=($( ErrorMessage " run.sh" " 0108" ) )
37+ echo $ERROR_MESSAGE && exit 1
4638fi
4739
4840CONFIG_JSON=$( node -e " console.log(JSON.stringify(require('./just.config.js')));" )
4941if [ $? -ne 0 ]; then
50- ERROR_MESSAGE=$( jq -r ' .["run.sh"][] | select(.code=="0109") | .message' " $ERRORS_FILE " )
51- ERROR_CODE=" 0109"
52- ERROR_LINK=$( jq -r ' .["run.sh"][] | select(.code=="0109") | .link' " $ERRORS_FILE " )
53- echo " Error $ERROR_CODE : $ERROR_MESSAGE $ERROR_LINK "
54- exit 1
42+ local ERROR_MESSAGE=($( ErrorMessage " run.sh" " 0109" ) )
43+ echo $ERROR_MESSAGE && exit 1
5544fi
5645echo " Parsed CONFIG_JSON: $CONFIG_JSON " # debug
46+ echo " $CONFIG_JSON " > " $CONFIG_DATA "
5747
5848if [ -z " $( echo " $CONFIG_JSON " | jq -r ' .module.exports' ) " ]; then
59- ERROR_MESSAGE=$( jq -r ' .["run.sh"][] | select(.code=="0112") | .message' " $ERRORS_FILE " )
60- ERROR_CODE=" 0112"
61- ERROR_LINK=$( jq -r ' .["run.sh"][] | select(.code=="0112") | .link' " $ERRORS_FILE " )
62- echo " Error $ERROR_CODE : $ERROR_MESSAGE $ERROR_LINK "
63- exit 1
49+ local ERROR_MESSAGE=($( ErrorMessage " run.sh" " 0112" ) )
50+ echo $ERROR_MESSAGE && exit 1
6451fi
6552
6653TYPE=$( echo " $CONFIG_JSON " | jq -r ' .type' )
6754if [ -z " $TYPE " ]; then
68- ERROR_MESSAGE=$( jq -r ' .["run.sh"][] | select(.code=="0110") | .message' " $ERRORS_FILE " )
69- ERROR_CODE=" 0110"
70- ERROR_LINK=$( jq -r ' .["run.sh"][] | select(.code=="0110") | .link' " $ERRORS_FILE " )
71- echo " Error $ERROR_CODE : $ERROR_MESSAGE $ERROR_LINK "
72- exit 1
55+ local ERROR_MESSAGE=($( ErrorMessage " run.sh" " 0110" ) )
56+ echo $ERROR_MESSAGE && exit 1
7357fi
7458
7559if [[ " $TYPE " != " postprocessor" && " $TYPE " != " redirect" ]]; then
76- ERROR_MESSAGE=$( jq -r ' .["run.sh"][] | select(.code=="0111") | .message' " $ERRORS_FILE " )
77- ERROR_CODE=" 0111"
78- ERROR_LINK=$( jq -r ' .["run.sh"][] | select(.code=="0111") | .link' " $ERRORS_FILE " )
79- echo " Error $ERROR_CODE : $ERROR_MESSAGE $ERROR_LINK (Got \" $TYPE \" )"
80- exit 1
60+ local ERROR_MESSAGE=($( ErrorMessage " run.sh" " 0111" ) )
61+ echo $ERROR_MESSAGE && exit 1
62+ fi
63+
64+ if [ -d " deploy" ]; then
65+ local ERROR_MESSAGE=($( ErrorMessage " important_dirs" " 0106" ) )
66+ echo $ERROR_MESSAGE && exit 1
67+ fi
68+ if [ -d " _just_data" ]; then
69+ local ERROR_MESSAGE=($( ErrorMessage " important_dirs" " 0107" ) )
70+ echo $ERROR_MESSAGE && exit 1
71+ fi
72+ mkdir -p deploy
73+ mkdir -p _just_data
74+
75+ if [ -d " deploy/_just" ]; then
76+ local ERROR_MESSAGE=($( ErrorMessage " postprocessor/modify_deployment.sh" " 0103" ) )
77+ echo $ERROR_MESSAGE && exit 1
8178fi
79+ mkdir -p deploy/_just/
8280
8381if [ " $TYPE " == " postprocessor" ]; then
84- bash $GITHUB_ACTION_PATH /src/postprocessor/checks.sh && \
82+ set -e
83+ postprocessor_checks=$( bash $GITHUB_ACTION_PATH /src/postprocessor/checks.sh 2>&1 ) || {
84+ local error_code=$?
85+ if [ $error_code -eq 1 ]; then
86+ local ERROR_MESSAGE=($( ErrorMessage " postprocessor/checks.sh" " 0100" " $postprocessor_checks " ) )
87+ if [ " $postprocessor_checks " == " 0101" ]; then
88+ ERROR_MESSAGE=($( ErrorMessage " postprocessor/checks.sh" " 0101" ) )
89+ fi
90+ echo $ERROR_MESSAGE && exit 1
91+ fi
92+ } && \
8593 bash $GITHUB_ACTION_PATH /src/postprocessor/prepare_deployment.sh && \
8694 bash $GITHUB_ACTION_PATH /src/postprocessor/create_api_endpoints.sh && \
8795 bash $GITHUB_ACTION_PATH /src/postprocessor/modify_deployment.sh && \
0 commit comments