forked from klutchell/mediaserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit
executable file
·27 lines (22 loc) · 896 Bytes
/
pre-commit
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
#!/bin/sh
# create `secrets.env` in the root of the repo to avoid committing sensitive
# details from your local configuration to git.
# add entries in the format "secret=placeholder" (placeholder can be blank)
# echo "[email protected][email protected]" >> secrets.env
# echo "secretdomain.com=exampledomain.com" >> secrets.env
# echo "abcdefghijklmnopqrstuvwxyz1234567890=" >> secrets.env
# install with:
# ln -s ../../pre-commit .git/hooks/pre-commit
# ln -s ../../post-commit .git/hooks/post-commit
[ -e "secrets.env" ] || exit
# remove secrets from docker-compose.yml and traefik.toml before git commit
for file in "docker-compose.yml" "traefik.toml"
do
cp "${file}" "${file}.bak"
while IFS='=' read -r secret text || [[ -n "${secret}" ]]
do
sed -e "s|${secret}|${text}|g" -i "${file}"
done < "secrets.env"
echo "removed secrets from ${file}"
git add ${file}
done