I want to deploy my app to Amazon ec2(Ubuntu instance) when my tests will be succeed.
1-)I have git hub repository which also a project and travis.yml.
2-)Travis can check my project and it succeed.
3-)When it succeed,a shell command should deploy my app to amazon ec2.(Confused Step)
I have learnt these but i can't do anything to
I know in travis.yml file should be like:
I know some answers but I couldn't solve. These are solutions to my problems.
after_success:
curl --ftp-create-dirs -T uploadfilename -u $FTP_USER:$FTP_PASSWORD ftp://sitename.com/directory/myfile
In this solution,I can't find my ftp_user and password,if i know them,is it possible to transfer data with using scp.
And the other solution is:(using pem file)
after_success:
scp -i "[pemFileName].pem" [A File] [hostname]@ec2-02-50-258-231.eu-central-1.compute.amazonaws.com:~/.
The code written after "after_success" is working from terminal but the problem in here is i can't upload my pem file to Travis.And i don't want to push pem file to github.(For security)
Briefly problem: How can i deploy my app to Amazon EC2 when my test succeed on travis?
Travis has the ability to encrypt/decrypt files stored in your git repository. You can store an encrypted version of your private key needed to scp
into your EC2 instance.
See https://docs.travis-ci.com/user/encrypting-files/.
In my case I use a Bash script that, if the right conditions are satisfied, (1) decrypts the file according to Travis' instructions; and then (2) scp
's the build over to the EC2 instance using the decrypted .pem key.
Note that your scp
command should incorporate some way to deal with StrictHostKeyChecking
. This will disable it entirely:
scp -i [path/to/id/file] -o StringHostKeyChecking=no [source] [destination]
Though a more secure route is to get the host key fingerprint (e.g., ssh-keyscan [host]
) and use as part of the scp
command:
scp -i [path/to/id/file] -o UserKnownHostsFile=path/to/custom/known_hosts [source] [destination]