-
Notifications
You must be signed in to change notification settings - Fork 0
/
wercker.yml
127 lines (114 loc) · 4.26 KB
/
wercker.yml
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
115
116
117
118
119
120
121
122
123
124
125
126
127
box: wercker/nodejs
build:
steps:
- script:
name: install grunt
code: sudo npm install grunt-cli -g
- npm-install
- npm-test
- script:
name: build assets
code: |
node build
- script:
name: echo nodejs information
code: |
echo "node version $(node -v) running"
echo "npm version $(npm -v) running"
deploy:
steps:
- install-packages:
packages: unzip
- script:
name: Install Beanstalk CLI
code: |-
wget --quiet https://s3.amazonaws.com/elasticbeanstalk/cli/AWS-ElasticBeanstalk-CLI-2.4.0.zip
unzip -qq AWS-ElasticBeanstalk-CLI-2.4.0.zip
sudo mkdir -p /usr/local/aws/elasticbeanstalk
sudo mv AWS-ElasticBeanstalk-CLI-2.4.0/* /usr/local/aws/elasticbeanstalk/
export PATH="/usr/local/aws/elasticbeanstalk/eb/linux/python2.7:$PATH"
export AWS_CREDENTIAL_FILE="/home/ubuntu/.elasticbeanstalk/aws_credential_file"
mkdir -p "/home/ubuntu/.elasticbeanstalk/"
mkdir -p "$WERCKER_SOURCE_DIR/.elasticbeanstalk/"
# Store the key and secret key in the the aws_credential_file
# This key and secret_key must be set as environment variable
# in your deploy target.
- create-file:
name: Create AWS credential file
filename: $AWS_CREDENTIAL_FILE
content: |-
AWSAccessKeyId=
AWSSecretKey=
# I'm not sure which information is mendatory, I've copied
# the full content from the config file on my local dev machine
# after a "eb init".
- create-file:
name: Add beanstalk config
filename: $WERCKER_SOURCE_DIR/.elasticbeanstalk/config
content: |-
[global]
ApplicationName=php-hello-world
DevToolsEndpoint=git.elasticbeanstalk.us-east-1.amazonaws.com
EnvironmentName=wercker
Region=us-east-1
ServiceEndpoint=https://elasticbeanstalk.us-east-1.amazonaws.com
[branches]
master=wercker
[branch:master]
ApplicationVersionName=master
EnvironmentName=wercker
InstanceProfileName=aws-elasticbeanstalk-ec2-role
# Check if beanstalk CLI is there
- script:
name: Beanstalk there?
code: eb status
# Remove the existing repository and re-add everything
# in a new repository that will be used to push it to beanstalk
# The last line in this script add the beanstalk hooks to the
# repository
- script:
name: Create deploy repository
code: |-
git config --global user.email "wiley@bmdware.com"
git config --global user.name "wiley"
rm -rf $WERCKER_SOURCE_DIR/.git
echo ".elasticbeanstalk/" > .gitignore
git init
git add .
git commit -m "deploy commit"
sudo bash /usr/local/aws/elasticbeanstalk/AWSDevTools/Linux/AWSDevTools-RepositorySetup.sh
# Do the actual deploy via the aws.push hook that the Beanstalk CLI adds
- script:
name: Push it!
code: |-
git checkout master
git aws.push
# deploy:
# steps:
# - add-to-known_hosts:
# hostname: helion.bmdware.com
# - mktemp:
# envvar: PRIVATEKEY_PATH
# - create-file:
# name: write key
# filename: $PRIVATEKEY_PATH
# content: $WERCKER_PRIVATE
# overwrite: true
# - script:
# name: transfer application
# code: |
# pwd
# ls -la
# ssh -i $PRIVATEKEY_PATH -l root helion.bmdware.com "rm -r /var/local/www"
# scp -i $PRIVATEKEY_PATH -r $WERCKER_SOURCE_DIR root@helion.bmdware.com:/var/local/www
# - script:
# name: npm configuration
# code: ssh -i $PRIVATEKEY_PATH -l root helion.bmdware.com "cd /var/local/www/ && npm config ls -l"
# - script:
# name: npm install
# code: ssh -i $PRIVATEKEY_PATH -l root helion.bmdware.com "cd /var/local/www/ && npm install --production"
# - script:
# name: start application
# code: |
# ssh -i $PRIVATEKEY_PATH -l root helion.bmdware.com "if [[ \"\$(status node-app)\" = *start/running* ]]; then stop node-app -n ; fi"
# ssh -i $PRIVATEKEY_PATH -l root helion.bmdware.com start node-app