@@ -4,6 +4,8 @@ CB="run-deploy.yaml"
4
4
ROUTE=" run-route.yaml"
5
5
M=" migrations.yaml"
6
6
7
+ services=(" API api.txt" " JOBS jobs.txt" " REWRITER rewriter.txt" " VIDEOMANIPULATOR videomanipulator.txt" " CMS cms.txt" )
8
+
7
9
function deploy {
8
10
echo " - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'" >> $CB
9
11
echo " waitFor: ['-']" >> $CB
@@ -35,20 +37,25 @@ function allow_loose {
35
37
echo " substitution_option: 'ALLOW_LOOSE'" >> $1
36
38
}
37
39
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
43
40
artifact pull workflow migrations.txt
44
41
45
42
# We always have migrations
46
43
echo " steps:" > $M
47
44
migrations $( cat migrations.txt)
48
45
artifact push workflow $M
49
46
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
52
59
exit 0
53
60
fi
54
61
@@ -58,30 +65,15 @@ echo "steps:" >> $CB
58
65
allow_loose $ROUTE
59
66
echo " steps:" >> $ROUTE
60
67
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)
65
71
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
85
77
86
78
artifact push workflow $CB
87
79
artifact push workflow $ROUTE
0 commit comments