Skip to content

Commit 12ccc69

Browse files
committed
ci: easier deploy script
1 parent 0de3a7e commit 12ccc69

File tree

1 file changed

+22
-30
lines changed

1 file changed

+22
-30
lines changed

scripts/generate-cloud-build.sh

+22-30
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CB="run-deploy.yaml"
44
ROUTE="run-route.yaml"
55
M="migrations.yaml"
66

7+
services=("API api.txt" "JOBS jobs.txt" "REWRITER rewriter.txt" "VIDEOMANIPULATOR videomanipulator.txt" "CMS cms.txt")
8+
79
function deploy {
810
echo "- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'" >> $CB
911
echo " waitFor: ['-']" >> $CB
@@ -35,20 +37,25 @@ function allow_loose {
3537
echo " substitution_option: 'ALLOW_LOOSE'" >> $1
3638
}
3739

38-
artifact pull workflow api.txt || true
39-
artifact pull workflow jobs.txt || true
40-
artifact pull workflow rewriter.txt || true
41-
artifact pull workflow videomanipulator.txt || true
42-
artifact pull workflow cms.txt || true
4340
artifact pull workflow migrations.txt
4441

4542
# We always have migrations
4643
echo "steps:" > $M
4744
migrations $(cat migrations.txt)
4845
artifact push workflow $M
4946

50-
if [ ! -f "api.txt" ] && [ ! -f "jobs.txt" ] && [ ! -f "cms.txt" ] && [ ! -f "rewriter.txt" ]; then
51-
# Nothing to do here, skip making workflows
47+
# Pull files
48+
SHOULD_DEPLOY=false
49+
for service in "${services[@]}"; do
50+
file=$(echo $service | cut -d' ' -f2)
51+
artifact pull workflow $file || true
52+
if [ -f "$file" ]; then
53+
SHOULD_DEPLOY=true
54+
fi
55+
done
56+
57+
# Quit if no services to deploy
58+
if [ "$SHOULD_DEPLOY" = false ]; then
5259
exit 0
5360
fi
5461

@@ -58,30 +65,15 @@ echo "steps:" >> $CB
5865
allow_loose $ROUTE
5966
echo "steps:" >> $ROUTE
6067

61-
if [ -f "api.txt" ]; then
62-
deploy API api.txt
63-
route API api.txt
64-
fi
68+
for service in "${services[@]}"; do
69+
name=$(echo $service | cut -d' ' -f1)
70+
file=$(echo $service | cut -d' ' -f2)
6571

66-
if [ -f "jobs.txt" ]; then
67-
deploy JOBS jobs.txt
68-
route JOBS jobs.txt
69-
fi
70-
71-
if [ -f "rewriter.txt" ]; then
72-
deploy REWRITER rewriter.txt
73-
route REWRITER rewriter.txt
74-
fi
75-
76-
if [ -f "videomanipulator.txt" ]; then
77-
deploy VIDEOMANIPULATOR videomanipulator.txt
78-
route VIDEOMANIPULATOR videomanipulator.txt
79-
fi
80-
81-
if [ -f "cms.txt" ]; then
82-
deploy CMS cms.txt
83-
route CMS cms.txt
84-
fi
72+
if [ -f "$file" ]; then
73+
deploy $name $file
74+
route $name $file
75+
fi
76+
done
8577

8678
artifact push workflow $CB
8779
artifact push workflow $ROUTE

0 commit comments

Comments
 (0)