- Add a
.travis.yml
file (like https://github.com/clirdlf/dashboard/blob/master/.travis.yml) - Add
gem 'html-proofer'
toGemfile
- Add a
script/cibuild
script (andchmod +x
) like https://github.com/clirdlf/dashboard/blob/master/script/cibuild. Adjust baseurl as needed. - Enable the repot on https://travis-ci.org
- Create a new bare repo in
/var/www
server$ sudo mkdir -p /var/www/[project_name]/shared/[project_name].git
server$ cd /var/www/[project_name]/shared/[project_name].git
server$ sudo git --bare init
server$ sudo mkdir -p /var/www/[project_name]/current
- Create a
post-receive
hook (hooks/post-receive
) - Make the hook executable (e.g.
chmod +x hooks/post-receive
)
- Create a new configuration in
/etc/apache2/sites-enabled
that ends in.conf
. - Enable the apache configuration (
sudo a2ensite [project_name]
) - Reload the apache2 daemon (
sudo service apache2 reload
)
- Add an
A
record for the project.
- Add the cert
server$ sudo certbot --apache -d [project_url] -d www.[project_url]
It's a good idea to have it automatically force SSL.
See the certbot install docs
This is only really necessary if there are multiple people working on the project on GitHub and you want to use GH for ACLs instead of syncing them on your server. Otherwise, just add a remote to the server (see below).
More info at https://blog.travis-ci.com/2017-11-01-security-advisory-ro-deploy-keys
- Generate a deployment key (if you don't have one already) in the project directory
local$ ssh-keygen -t rsa -b 4096 -C '[email protected]' -f ./deploy_rsa
- Encrypt the private key
local$ travis encrypt-file deploy_rsa --add
- Copy the deployment key to server
local$ ssh-copy-id -i ~/.ssh/deploy_rsa.pub <ssh_user>@<host>
- Move the keys to
~/.ssh
(`mv deploy_rsa deploy_rsa.pub ~/.ssh) - Add the encrypted file
git add deploy_rsa.enc
- Navigate to the repository settings on GitHub and add a deploy key (the contents of
deploy_rsa.pub
). - Add a new section for
after_success
in the.travis.yml
https://docs.travis-ci.com/user/deployment/custom/#Git
addons:
ssh_known_hosts:
- <server>
before_install:
- openssl aes-256-cbc -K $encrypted_<...>_key -iv $encrypted_<...>_iv -in deploy_rsa.enc -out /tmp/deploy_rsa -d -in deploy_rsa.enc -out deploy_rsa -d
after_success:
- eval "$(ssh-agent -s)" #start the ssh agent
- chmod 600 /tmp/deploy_rsa
- ssh-add /tmp/deploy_rsa
- git remote add deploy $git_remote
- git push deploy
Be sure to check the $encrypted_
and $encrypts_<...>_iv
values from the Travis settings.
While you're getting the correct key variables, create a new $git_remote
variable with the complete ssh string (e.g. ssh://username@server:/var/www/[project_name]/shared/[project_name].git
).
laptop$ git remote add production ssh://username@server:/var/www/[project_name]/shared/[project_name].git
laptop$ git push production +master:refs/heads/master