Deploy using GitHub Actions

Deploy using GitHub Actions

We have been asked multiple times in the past if deployment from a GitHub repository is supported on EvenNode. The short answer is yes 😊

You could have either used git deployment to deploy your GitHub project or you could have set up GitHub Actions to deploy your app automatically on each commit. The latter was not well documented though. Today we bring you a guide to help you deploy your application to EvenNode using GitHub Actions. Enjoy!

Configure GitHub Actions

GitHub Actions is a tool which helps automate tasks such as testing or deployment automatically when a certain event occurs, such as:

  • A pull request is created
  • Branch is updated
  • Change is committed to the master branch
  • etc.

Configuration of GitHub Actions is done through workflow files typically named workflow.yml. It defines events which trigger a workflow and actions the workflow shall perform. GitHub Marketplace is a great repository of ready-made actions you can use to automate all sorts of tasks.

By combining a couple of the available actions, I'll show you how you can easily deploy your application to EvenNode on every commit or a pull request.

The workflow file is very simple. The workflow is triggered on every commit to the master branch and performs the following actions:

  • Saves your private key into the proper location
  • Adds git.evennode.com into known_hosts file
  • Checks out your code
  • Deploys your application to EvenNode

You can find a repository with the full example of GitHub Actions workflow in evennode/github-actions-deploy-to-evennode.

Deployment variables (secrets)

There are 4 variables you need to configure to deploy your app directly to EvenNode with this workflow. All the variables are configured in Settings > Secrets section of your GitHub repository.

  1. SSH_KEY - Your private SSH key used to deploy your app to EvenNode
  2. EVENNODE_REPO_URL - Your app's EvenNode repository url such as git@git.evennode.com:myapplication.git. The url can be found on the overview page of your app
  3. GIT_EMAIL - Email to be used to push your code. It does not have to be the same email you have with us at EvenNode.
  4. GIT_NAME - Your name used to push your code.

The GIT_EMAIL and GIT_NAME variables are required by git to deploy your application to EvenNode and are not related in any way to your credentials with EvenNode.

All variables can be configured on GitHub in the repository of your application in the Settings > Secrets section. It shall look something like this:

After the configuration is ready, commit and push changes to your master branch and watch GitHub Actions deploy your application to EvenNode 🎉💕✨

Final thoughts

GitHub Actions workflow is a great way to automate deployment of your application to EvenNode. Try it yourself:

Share with us your story how GitHub Actions helped you automate deployment workflow 🐱‍🐉