Skip to content

Commit bc928fa

Browse files
committed
feat: a push utility to push multiple pipes with match conditions
1 parent 0e44f14 commit bc928fa

File tree

1 file changed

+64
-0
lines changed
  • services/libs/tinybird/scripts

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
PIPES_FOLDER="pipes"
4+
5+
cd "$(dirname "$0")/.." || exit 1
6+
7+
show_help() {
8+
cat << EOF
9+
Usage: push.sh [OPTIONS]
10+
11+
Push Tinybird pipe files using "tb push".
12+
13+
OPTIONS:
14+
--help Show this help message and exit
15+
--match PATTERN Match files containing PATTERN in their name (wildcard match)
16+
17+
EXAMPLES:
18+
push.sh
19+
Push all pipe files
20+
21+
push.sh --match leaderboards_
22+
Push only files containing "leaderboards_" in their name
23+
24+
EOF
25+
exit 0
26+
}
27+
28+
# Parse command line arguments
29+
MATCH_PATTERN=""
30+
31+
while [[ $# -gt 0 ]]; do
32+
case $1 in
33+
--help|-h)
34+
show_help
35+
;;
36+
--match)
37+
if [ -z "$2" ] || [[ "$2" == --* ]]; then
38+
echo "Error: --match requires a pattern argument"
39+
echo ""
40+
show_help
41+
fi
42+
MATCH_PATTERN="$2"
43+
shift 2
44+
;;
45+
*)
46+
echo "Error: Unknown option: $1"
47+
echo ""
48+
show_help
49+
;;
50+
esac
51+
done
52+
53+
for file in "$PIPES_FOLDER"/*; do
54+
if [ -f "$file" ]; then
55+
local_basename=$(basename "$file")
56+
57+
# Skip file if pattern is set and doesn't match
58+
if [ -n "$MATCH_PATTERN" ] && [[ ! "$local_basename" == *$MATCH_PATTERN* ]]; then
59+
continue
60+
fi
61+
62+
tb push "pipes/$local_basename" --force --yes
63+
fi
64+
done

0 commit comments

Comments
 (0)