-
Notifications
You must be signed in to change notification settings - Fork 1
/
__first_time.sh
executable file
·108 lines (89 loc) · 2.67 KB
/
__first_time.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
#!/usr/bin/env bash
# Remove on the runner.
RUNNER_TEMP="/tmp/terraform-makefile"
# Clone repo into TMP directory.
rm -Rf "${RUNNER_TEMP}"
git clone \
--depth 1 \
--branch main \
--single-branch \
https://github.com/northwood-labs/.github.git \
"${RUNNER_TEMP}" \
;
# Copy all "full-copy" files from the root into the repository.
find "${RUNNER_TEMP}/full-copy/" -maxdepth 1 -type f -print0 |
xargs -0 -I% cp -Rfv "%" "${PWD}" ||
true
# Folders to copy
FOLDERS=(
".githooks"
".github"
"scripts"
)
for FOLDER in "${FOLDERS[@]}"; do
# Copy all files from this directory into the root of the repository.
mkdir -p "${PWD}/${FOLDER}"
find "${RUNNER_TEMP}/full-copy/${FOLDER}/" -maxdepth 1 -type f -print0 |
xargs -0 -I% cp -Rfv "%" "${PWD}/${FOLDER}" ||
true
done
TYPES=()
# Pass GO=true when calling the script.
# shellcheck disable=2154
if [[ "${GO}" == "true" ]]; then
TYPES+=("go")
fi
# Pass TF=true when calling the script.
# shellcheck disable=2154
if [[ "${TF}" == "true" ]]; then
TYPES+=("tf")
fi
for TYPE in "${TYPES[@]}"; do
# Copy all files from this directory into the root of the repository.
mkdir -p "${PWD}"
find "${RUNNER_TEMP}/full-copy/${TYPE}/" -maxdepth 1 -type f -not \( -name "*tmpl*" \) -print0 |
xargs -0 -I% cp -Rfv "%" "${PWD}" ||
true
done
# Copy all "updates" files from the root into the repository.
find "${RUNNER_TEMP}/updates/" -maxdepth 1 -type f -not \( -name "*tmpl*" \) -print0 |
xargs -0 -I% cp -Rfv "%" "${PWD}" ||
true
# Folders to copy
FOLDERS=(
".github"
".vscode"
)
for FOLDER in "${FOLDERS[@]}"; do
# Copy all files from this directory into the root of the repository.
mkdir -p "${PWD}/${FOLDER}"
find "${RUNNER_TEMP}/updates/${FOLDER}/" -maxdepth 1 -type f -not \( -name "*tmpl*" \) -print0 |
xargs -0 -I% cp -Rfv "%" "${PWD}/${FOLDER}" ||
true
done
TYPES=()
# Pass GO=true when calling the script.
# shellcheck disable=2154
if [[ "${GO}" == "true" ]]; then
TYPES+=("go")
fi
# Pass TF=true when calling the script.
# shellcheck disable=2154
if [[ "${TF}" == "true" ]]; then
TYPES+=("tf")
fi
for TYPE in "${TYPES[@]}"; do
# Copy all files from this directory into the root of the repository.
mkdir -p "${PWD}"
find "${RUNNER_TEMP}/updates/${TYPE}/" -maxdepth 1 -type f -not \( -name "*tmpl*" \) -print0 |
xargs -0 -I% cp -Rfv "%" "${PWD}" ||
true
done
# Run Goplicate
goplicate run --allow-dirty --confirm --stash-changes
# Generate .ecrc
tomljson ecrc.toml >.ecrc
# Make shell scripts executable
find "${PWD}" -type f -name "*.sh" -print0 |
xargs -0 -I% chmod +x "%" ||
true