openstatus logoPricingDocsDashboard

How We Built our own GitHub Action

Feb 26, 2025 | by Thibault Le Ouay Ducasse | [engineering]

How We Built our own GitHub Action

A couple of weeks ago, when we released our CLI, we wanted to use it to run our own Synthetics Tests in a GitHub Action. We aimed to have a simple way to run our tests on every push to our main branch or on a schedule.

There are three ways to build a GitHub Action:

  • Composite actions
  • Javascript actions
  • Docker container actions

Our CLI is built in Golang, and we publish every new version as a binary. It made sense to go with the Docker container actions. This way we could use our CLI to run the tests.

We needed to have a way to pass the API key and the configuration file to the action.

Let's start our speedrun on building our own custom Docker GitHub Action.

Create a Dockerfile

Our Docker file is pretty simple. We use the alpine image and install curl to download the CLI. We then extract the CLI and set the entrypoint to the entrypoint.sh file.

FROM alpine:3.21.3

RUN apk --no-cache add curl

WORKDIR /home/openstatus

COPY entrypoint.sh .

RUN  curl -o cli.tar.gz -L  https://github.com/openstatusHQ/cli/releases/latest/download/cli_Linux_x86_64.tar.gz

RUN tar -xf ./cli.tar.gz

ENTRYPOINT ["/home/openstatus/entrypoint.sh"]

It results in a small image of around 25 MB, which is perfect for a GitHub Action.

To download the latest version of the CLI we use the following URL.

https://github.com/openstatusHQ/cli/releases/latest/download/cli_Linux_x86_64.tar.gz

Our entrypoint.sh file is also quite simple. We just run the CLI with the API key and the configuration file.

#!/bin/sh

if [ -z "$INPUT_CONFIG_PATH" ]; then
    /home/openstatus/openstatus run --access-token $INPUT_API_KEY
else
    /home/openstatus/openstatus run --access-token $INPUT_API_KEY --config $INPUT_CONFIG_PATH
fi

if [ $? -eq 0 ]
then
    echo "OpenStatus run successfully"
    exit 0
else
    echo "OpenStatus run failed"
    exit 1
fi

Create the action.yml file

Our action.yml file

name: 'OpenStatus Synthetics CI'
description: 'Run your OpenStatus synthetics checks as part of your GitHub Actions workflow.'
author: 'OpenStatus'
branding:
  icon: 'zap'
  color: gray-dark

inputs:
  api_key:
    description: 'OpenStatus API key'
    required: true
  config_path:
    description: 'Path to the OpenStatus configuration file'
    required: false

runs:
  using: docker
  image: docker://ghcr.io/openstatushq/action:latest
  args:
    - ${{ inputs.api_key }}
    - ${{ inputs.config_path }}

That's all you need to build your own Docker custom GitHub Action.

I struggle a bit with the GitHub action because the docker image was being built on the fly. I had to push the image to the GitHub Container Registry to be able to use it in the action. You can use any other container registry but GitHub Container Registry is free for public repositories.

The solution was to change the image in the action.yml file to the image in the GitHub Container Registry.

From:

image: Dockerfile

To:

image: docker://ghcr.io/openstatushq/action:latest

Publish it to the GitHub marketplace

Add branding to your action and your action is ready. You can publish it to the GitHub Marketplace.

Conclusion

Building a GitHub Action is pretty simple. We choose to use a Docker container action because we wanted to use our CLI to run the tests.

If you want to start using our action you can find it in the GitHub Marketplace.

https://github.com/marketplace/actions/openstatus-synthetics-ci

If you want to see a GitHub repository with the action you can find it here.

https://github.com/openstatusHQ/github-action-tester/actions

Create an account on OpenStatus and start running your own Synthetics Tests in your GitHub Actions.