|
3 | 3 | source "${GITHUB_ACTION_PATH}/util.sh" |
4 | 4 |
|
5 | 5 | pathsToCopy="$1" |
6 | | -# Copy paths to render dir |
7 | | -for row in $(echo "${pathsToCopy}" | jq -c '.[]'); do |
| 6 | + |
| 7 | +copy() { |
| 8 | + local row=$1 |
| 9 | + local destination_base=$2 |
| 10 | + |
8 | 11 | _jq() { |
9 | 12 | echo ${row} | jq -r ${1} |
10 | 13 | } |
| 14 | + |
11 | 15 | copy=$(_jq '.if') |
12 | 16 | source=$(_jq '.source') |
13 | 17 | target=$(_jq '.target') |
14 | 18 |
|
15 | 19 | if [ "${copy}" = true ]; then |
16 | | - echo "Copying from ${RENDER_DIR?}/${target}" |
17 | | - mkdir -p $(dirname "${RENDER_DIR?}/${target}") && cp -r "./${source}" "${RENDER_DIR?}/${target}" |
| 20 | + echo "Copying from ${destination_base}/${target}" |
| 21 | + mkdir -p $(dirname "${destination_base}/${target}") && cp -r "${source}" "${destination_base}/${target}" |
| 22 | + [[ $3 == "git_add" ]] && git add "./${target}" |
18 | 23 | else |
19 | | - echo "Skipping copy to render dir for ${source}" |
| 24 | + echo "Skipping copy to ${destination_base} for ${source}" |
20 | 25 | fi |
| 26 | +} |
| 27 | + |
| 28 | +# Copy paths to render dir |
| 29 | +for row in $(echo "${pathsToCopy}" | jq -c '.[]'); do |
| 30 | + copy "${row}" "${RENDER_DIR}" |
21 | 31 | done |
22 | 32 |
|
23 | 33 | # Base changes off the branch being deployed to |
|
68 | 78 | git add --all -fv . |
69 | 79 | fi |
70 | 80 |
|
71 | | -#Copy from render dir to branch |
| 81 | +# Copy from render dir to branch |
72 | 82 | for row in $(echo "${pathsToCopy}" | jq -c '.[]'); do |
73 | | - _jq() { |
74 | | - echo ${row} | jq -r ${1} |
75 | | - } |
76 | | - copy=$(_jq '.if') |
77 | | - target=$(_jq '.target') |
78 | | - |
79 | | - if [ "${copy}" = true ]; then |
80 | | - echo "Copying from ${RENDER_DIR?}/${target} to ./${target}" |
81 | | - mkdir -p $(dirname "./${target}") && cp -r "${RENDER_DIR?}/${target}" "./${target}" |
82 | | - git add "./${target}" |
83 | | - else |
84 | | - echo "Skipping copy to branch for ${source}" |
85 | | - fi |
| 83 | + copy "${row}" "." "git_add" |
86 | 84 | done |
0 commit comments