-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
114 lines (100 loc) · 4.23 KB
/
build.xml
File metadata and controls
114 lines (100 loc) · 4.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<project name="zf2-demo" default="help" basedir=".">
<import file="./vendor/continuousphp/aws-sdk-phing/tasks.xml" />
<if>
<available file="${project.basedir}/build.local.properties" />
<then>
<property file="${project.basedir}/build.local.properties" />
</then>
</if>
<property file="${project.basedir}/build.properties" />
<if>
<isset property="continuousphp.pr" />
<then>
<echo message="Switching to PR stack" />
<property name="cf.filteredStackName"
value="${cf.stackName}-${continuousphp.pr}" />
</then>
<else>
<property name="cf.filteredStackName"
value="${cf.stackName}" />
</else>
</if>
<target name="help" description="List available targets">
<exec executable="vendor/bin/phing"
passthru="true">
<arg value="-l"/>
</exec>
</target>
<target name="setup-aws">
<aws-config region="${aws.region}" profile="${aws.profile}" />
</target>
<target name="run-stack">
<aws-cf-runstack
name="demo-${cf.filteredStackName}"
updateOnConflict="true"
capabilities="CAPABILITY_IAM"
templatePath="./infra/single-server.template">
<param name="KeyName" value="${cf.KeyName}" />
<param name="env" value="${cf.filteredStackName}" />
</aws-cf-runstack>
</target>
<target name="setup-deployment-group">
<aws-deploy-deployment-group
name="${cf.filteredStackName}"
updateOnConflict="true"
deploymentConfigName="CodeDeployDefault.OneAtATime"
serviceRole="${deploy.serviceRole}"
application="${deploy.applicationName}">
<ec2TagFilter key="env" value="${cf.filteredStackName}" />
</aws-deploy-deployment-group>
</target>
<!-- create database -->
<target name="init-db" description="Create Database and Grants">
<mkdir dir="${project.basedir}/data/db"/>
<echo file="${project.basedir}/data/db/create.sql">
CREATE DATABASE IF NOT EXISTS ${db.dbname};
</echo>
<pdosqlexec url="mysql:host=${db.host}" userid="${db.username}" password="${db.password}">
<transaction src="${project.basedir}/data/db/create.sql"/>
</pdosqlexec>
<delete dir="${project.basedir}/data/db" quiet="true"/>
</target>
<!-- Migrate Database -->
<target name="migrate-db" description="Update the database version">
<exec command="${doctrine.bin} migrations:migrate --no-interaction"
outputProperty="doctrine.output"/>
<echo msg="${doctrine.output}" />
<if>
<contains string="${doctrine.output}" substring="Could not find any migrations to execute." />
<else>
<exec command="${doctrine.bin} orm:clear-cache:metadata" passthru="true"/>
<exec command="${doctrine.bin} orm:clear-cache:query" passthru="true"/>
</else>
</if>
</target>
<!-- generate config -->
<target name="generate-config">
<copy todir="${project.basedir}/config"
overwrite="true">
<fileset dir="${project.basedir}/config">
<include name="**/*.local.php.dist" />
</fileset>
<mapper type="glob" from="*.local.php.dist" to="*.local.php" />
<filterchain>
<replacetokens>
<token key="db.host" value="${db.host}" />
<token key="db.port" value="${db.port}" />
<token key="db.dbname" value="${db.dbname}" />
<token key="db.username" value="${db.username}" />
<token key="db.password" value="${db.password}" />
</replacetokens>
</filterchain>
</copy>
</target>
<target name="provision-stack"
description="Provision a stack on AWS"
depends="setup-aws, run-stack, setup-deployment-group" />
<target name="setup"
description="Setup external dependencies and migrate data"
depends="generate-config, init-db, migrate-db"/>
</project>