Automated deployment

Anybody could give me any pointers on where to start for automatic deployments?

Let’s say I would like every commit to github to be automatically deployed to my staging server?

1 Like

You would need some type of continuous integration or continuous delivery server set up.

A lot of people use GitLab’s CI server, or Codeship, or another paid CI/CD service to run Ansible commands on successful commits.

2 Likes

Definitely will look into Gitlab’s CI server. Looks interesting… And free!?!

Thanks! :metal:

You ever get this setup? Looking to do the same!

No I did not, yet … haha.

If anyone has I’d love to see a walkthrough of how you did it-- currently working on it myself but only have time here and there.

After setting up the gitlab-ci-multi-runner “shell” on my macos, I am able to trigger a deploy when a commit is pushed to my develop branch. If that can help you start. I’d be curious to see a more complete .gitlab-ci.yml if someone has one to share.

before_script:

  • “cd trellis && ansible-galaxy install -r requirements.yml”

deploy_dev:
script: “./deploy.sh production dev.example.com
only:
- develop

4 Likes

Hey,

It would be nice if someone could make a tutorial on how to setup GitLab CI with Trellis. It would be awesome addition intro Trellis workflow.

Maby someone has links where is enough info about setting it up? I would be willing to create a tutorial for Trellis, maby even a video. Cheers!

We have open sourced our CircleCI config at https://github.com/ItinerisLtd/circleci-orbs-wordpress/blob/74f1609f16c1da5eff872f4ba20525d6ecde7bd4/src/tiller-circleci/orb.yml and the Dockerfile at https://github.com/ItinerisLtd/circleci-orbs-wordpress/blob/74f1609f16c1da5eff872f4ba20525d6ecde7bd4/src/tiller-circleci/Dockerfile You might want to convert them into GitLab CI ones.

Tips: Make sure you setup the SSH keys correctly.

3 Likes

Tips: Make sure you setup the SSH keys correctly.

@TangRufus, regarding your tip to use SSH correctly.
I have added my server private key to CircleCI project settings with a blank hostname but during the deployment it fails due to publickey. I can SSH into the host with the private key and run deployments locally.

Looking at CircleCI documentation (Add additional SSH keys to CircleCI - CircleCI) I’m seeing that I need to add the ssh key fingerprint. How would I do this with this orb?

Thank you.

I recommand using adding a GitHub user key to CircleCI for simplicity.

To do so:

  1. go to your project’s ssh key settings page on CircleCI
  2. add a user key (the one that you need to authenticate with GitHub)
  3. remove all other ssh key
  4. go to https://github.com/.keys
  5. you should find the newly generated public key at the end
  6. add it to https://github.com/roots/trellis/blob/master/group_vars/all/users.yml#L6-L11 (If it is okay for you, just add the line - https://github.com/<your-username>.keys)
  7. re-provision
  8. re-run the deploy workflow, it should just work

Note: Make sure your GitHub user has read access to the trellis repo, the bedrock repo, and other plugin repos (if you composer install via private github repos)

Recommandation: Create a bot account on GitHub, grant it read access to all the nessary repos. Then, use it as the user on CircleCI.


If you really want to add a specific ssh key on CircleCI,

  1. added your public key to CircleCI project settings with your host’s hostnames or IPs
  2. Generate the fingerprint
  3. Edit your CircleCI config - add add_ssh_keys as the job’s pre-steps or setup

P.S. I have left Itineirs. If you find any bugs or have suggestions to the orb, please create an issue on https://github.com/ItinerisLtd/tiller-circleci-orb
I am sure the Itineris team is happy to help.

1 Like

Thanks for the explanation.

I managed to get it working with assigning a public key using the orbs “setup” job. Like this:

workflows:
deploy:
jobs:
- tiller-monorepo-circleci/deploy:
setup:
- add_ssh_keys
name: deploy-staging

1 Like