amazon web services - Is there a way to get a github PR merge to trigger an EC2 instance to start? -


we're trying ec2 instance start whenever merge pull request in github.

i have in crontab

@reboot /home/user/server-start.sh 

which want happen (like git pull origin master) when instance starts up, , script works well.

i've looked @ aws codedeploy can't see way have turn instance on (this server turned off, needs turn on , stuff when merge pr, turn off again)

i'm not sure best approach be, pointers great.

here's startup script , nginx server config file, in case helpful.

/home/user/server-startup.sh

#!/bin/bash  # latest master branch cd /path/to/repo sudo git pull origin master  # run standard preparation script sudo bash /home/user/scripts/prepare-app.sh  # run custom commands update sudo bash /path/to/repo/prepare-app.sh  # change http code 200 sudo sed -i -e 's/return 500/return 200/g' /etc/nginx/sites-available/status  # restart nginx sudo service nginx restart  # change http code 500 sudo sed -i -e 's/return 200/return 500/g' /etc/nginx/sites-available/status 

/etc/nginx/site-available/status

server {     listen      80 default_server;     server_name status.mydomain.com;      location / {         return 500;     } } 

if instance stopped, not terminated use aws cli start instance:

aws ec2 start-instances --instance-ids i-1348636c 

docs: https://aws.amazon.com/cli/

this code triggered git hook: https://git-scm.com/book/en/v2/customizing-git-git-hooks.

the rest of script run when instance has finished starting need sort of health check on server.

you consider ci/cd tools if want bit more manageable e.g. bamboo / codeship.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -