Member-only story

Deploy Your Code To The Production Environment From Github

İbrahim Gündüz
2 min readJun 20, 2020

--

As you know, Github allows us to execute continuous integration pipelines through Actions easily. Today, we are going to see how to deploy your code directly from Github to your server by using Ansible, Docker, and Github Actions.

What Is Challenge Here?

Ansible is an IT automation tool that communicates to servers via SSH protocol without using any agent mechanism. It allows you to execute commands on remote servers or transferring files to servers from the system where you run the Ansible playbook. So the key problem is being able to access the remote servers from a public system like Github.

How To Solve?

We can execute the Ansible playbooks in a docker container through Github Actions by using a specific private key that eligible to access the remote servers.

How To Do?

  • Encrypt the private key you used to access the remote servers by using Ansible Vault.
$ echo "your-secret-password" > ansible_vault_password.txt &&\
ansible-vault \
encrypt \
--vault-password-file=ansible_vault_password.txt \
~/.ssh/id_rsa \
--output=id_rsa-encrypted &&\
rm ansible_vault_password.txt
  • Create a Dockerfile like the following one that you will execute the…

--

--

No responses yet