Actions Runner on DigitalOcean App Platform
Tags: dohackathon, actionshackathon, devops, github
Published: 2021-01-07 00:01:45

This is the third and final article of the series [Trying DigitalOcean App Platform](https://dev.to/thewdhanat/series/10547) which is part of [DigitalOcean App Platform Hackathon](https://dev.to/devteam/announcing-the-digitalocean-app-platform-hackathon-on-dev-2i1k). This is also my official submission for the hackathon.

## What I built

GitHub Actions self-hosted runner docker on DigitalOcean App Platform worker.

[![Deploy to DO](https://mp-assets1.sfo2.digitaloceanspaces.com/deploy-to-do/do-btn-blue.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/ThewBear/do-actions-runner/tree/main&refcode=61b92fc0f519)

Currently, we **cannot** deploy a new app that only has the worker. So you need to create a new app with a service then delete that service and create a worker.

### Category Submission: 

Random Roulette

### Screenshots

GitHub settings

![Actions self-hosted settings](https://dev-to-uploads.s3.amazonaws.com/i/v24f3j6d311cj5gw5nru.png)

DigitalOcean dashboard

![DigitalOcean App Platform dashboard](https://dev-to-uploads.s3.amazonaws.com/i/unzewo6pk3td9yd9zqnh.png) 
 
### Description

This is a [self hosted](https://docs.github.com/en/free-pro-team@latest/actions/hosting-your-own-runners/about-self-hosted-runners) GitHub Actions runner for deploying to [DigitalOcean App Platform](https://www.digitalocean.com/products/app-platform/). You will get the simplicity of automated cluster deployment and [scaling](https://www.digitalocean.com/docs/app-platform/concepts/scaling/) by DigitalOcean App Platform.

It will register and remove itself automatically when DigitalOcean App Platform start and stop [the container](https://www.digitalocean.com/docs/app-platform/concepts/container/). You can [vertical scale or horizontal scale](https://www.digitalocean.com/docs/app-platform/how-to/scale-app/) your runner. If you do a horizontal scale (Pro plan only), all runners will be automatically registered to GitHub.

![Horizontally scaled runners are registered automatically](https://dev-to-uploads.s3.amazonaws.com/i/3egdqnfi67zztcjmnhzd.png) 

### Link to Source Code

{% github ThewBear/do-actions-runner no-readme %}

### Permissive License

MIT License

## Background

I built this app to trying out DigitalOcean App Platform worker and GitHub Actions self-hosted at the same time.

The DigitalOcean App Platform worker is a running server-side code that is not internet-accessible. Because workers can not accept HTTP requests, they are only suitable for doing background tasks, such as queue processing.

The GitHub Actions self-hosted runners offer more control of software tools than GitHub-hosted runners provide. With self-hosted runners, you can choose to increase processing power or memory, install custom software, and choose an operating system not offered by GitHub-hosted runners. In our case, this is done by modifying `Dockerfile` and scaling the component.

### How I built it 

I built it by looking through existing resources about self-hosted actions runner docker. Here are some of them:

- [GitHub Actions self-hosted runners on Google Cloud
](https://github.blog/2020-08-04-github-actions-self-hosted-runners-on-google-cloud/)
- [Running self-hosted GitHub Actions runners in your Kubernetes cluster](https://sanderknape.com/2020/03/self-hosted-github-actions-runner-kubernetes/)
- [Deploying Self-Hosted Github Actions Runners with Docker](https://testdriven.io/blog/github-actions-docker/)
- [myoung34/docker-github-actions-runner](https://github.com/myoung34/docker-github-actions-runner)
- [samber/github-actions-runner](https://github.com/samber/github-actions-runner)
- [actions/virtual-environments](https://github.com/actions/virtual-environments)

Then I create a `Dockerfile` and `entrypoint.sh`.

### Additional Resources/Info

<a href="https://www.buymeacoffee.com/thew" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee"></a>