-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage-secrets.sh
More file actions
executable file
·45 lines (39 loc) · 907 Bytes
/
manage-secrets.sh
File metadata and controls
executable file
·45 lines (39 loc) · 907 Bytes
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
#!/usr/bin/env bash
# Manage secrets via git-secret
set -euo pipefail
print_usage() {
cat <<USAGE
Usage: $0 <command> [args]
Commands:
init [KEY ...] Initialize git-secret and authorize GPG keys (e.g. email or key IDs)
add <file>... Add secret file(s) to git-secret path mappings
hide Encrypt all added secrets
reveal Decrypt all secrets
help Show this usage message
USAGE
}
cmd="${1:-help}"
shift || true
case "$cmd" in
update)
changed_files=$(ls -la ./secrets/)
for file in $changed_files; do
# skip extension is .secret
if [[ "$file" == *.secret ]]; then
continue
fi
if [ "$file" = "./secrets/*" ]; then
git secret add "$file"
fi
done
git secret hide
;;
help)
print_usage
;;
*)
echo "Unknown command: $cmd"
print_usage
exit 1
;;
esac