Deep look into Production Ready Git Actions | Self-Hosted Runners

Parteek Sharma
3 min readMay 4, 2021

GitHub Actions is a Ci/Cd tool that makes it easier to automate how you build, test, and deploy your projects on any platform, including Linux, macOS, and Windows. Run your workflows in a container or in a virtual machine. Actions also supports more languages and frameworks than ever, including Node.js, Python, Java, PHP, Ruby, C/C++, .NET, Android, and iOS.

In this post we are going to build our python app to our AWS server. Create a workflow file. At last, Install the Actions runner on your VM and register them with Actions.

Workloads that execute on self-hosted runners are free. All these step are gonna perform in our server only.

1st step : Setting up Workflow file

  1. Open or create a repo in github.com and navigate to actions.
Action tab in github.com

2. Select an appropriate action template. GitHub supports bunch of different environments and languages. Example : I am selecting Python. You can make your own workflow file if you want. But it is recommended that you choose a template and make modification there.

Workflow Templates

3. To use our own server change the runs-on value to self-hosted.

Setting self-hosted server

4. press on Start commit button on top-right corner (green color) and then press on commit changes.

5. Go to actions tab again and You’ll see Red crosses. click on one of them and you will see the complete logs.

build error : No runner matching the specified labels was found

6. Now we will setup our own runner in next step.

2nd Step : Setting up GitHub action runner

Runner is a server where all the step we defined in workflow file will execute.

  1. Navigate to Settings tab and click on Actions (left sidebar).
  2. Scroll down and click on Add runner (green color)
  3. Now select Linux in operating system dropdown and X64 as Architecture.
Navigate to settings>actions>new runner

3rd Step : Login to own server and setting up Actions in server

  1. Login to server . Copy and paste the commands shown in the page and run them on your server.
Screenshots of commands to setup actions in server

2. Now after completing all above commands you can see your runner in setting>actions. We can now start our workflow but this always need to run ./run.sh file in our server before running workflow in GitHub.com. To solve this problem we can make our server/runner to always stay live.

For the runner to always stay live we need to execute below commands instead of ./run.sh

sudo ./svc.sh install

sudo ./svc.sh start

You can check the status of the runner using sudo ./svc.sh status. Now the runner can be used anytime without running ./run.sh manually in server every time we need to run our workflow.

4th step : Restarting our actions.

  1. Go to the actions as defined in 1st step and click on latest action performed.
  2. Click on Re-run jobs.
  3. You will see the actions are performing step by step as per workflow file.

--

--

Parteek Sharma

Python Developer. Experienced in Django, Flask, Fast api. Intern @ adcuratio media. Love to solve Problems related to my intrest😀