-
Notifications
You must be signed in to change notification settings - Fork 731
Expand file tree
/
Copy pathpush.sh
More file actions
executable file
·64 lines (51 loc) · 1.23 KB
/
push.sh
File metadata and controls
executable file
·64 lines (51 loc) · 1.23 KB
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
#!/bin/bash
PIPES_FOLDER="pipes"
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.." || exit 1
show_help() {
cat << EOF
Usage: push.sh [OPTIONS]
Push Tinybird pipe files using "tb push".
OPTIONS:
--help Show this help message and exit
--match PATTERN Match files containing PATTERN in their name (wildcard match)
EXAMPLES:
push.sh
Push all pipe files
push.sh --match leaderboards_
Push only files containing "leaderboards_" in their name
EOF
exit 0
}
# Parse command line arguments
MATCH_PATTERN=""
while [[ $# -gt 0 ]]; do
case $1 in
--help|-h)
show_help
;;
--match)
if [ -z "$2" ] || [[ "$2" == --* ]]; then
echo "Error: --match requires a pattern argument"
echo ""
show_help
fi
MATCH_PATTERN="$2"
shift 2
;;
*)
echo "Error: Unknown option: $1"
echo ""
show_help
;;
esac
done
for file in "$PIPES_FOLDER"/*; do
if [ -f "$file" ]; then
local_basename=$(basename "$file")
# Skip file if pattern is set and doesn't match
if [ -n "$MATCH_PATTERN" ] && [[ ! "$local_basename" == *$MATCH_PATTERN* ]]; then
continue
fi
tb push "$PIPES_FOLDER/$local_basename" --force --yes
fi
done