···11+---
22+title: How We Built our own GitHub Action
33+description:
44+ A speedrun on building our own custom Docker GitHub Action to run OpenStatus Synthetics Tests on every push to our main branch and on a schedule.
55+author:
66+ name: Thibault Le Ouay Ducasse
77+ url: https://bsky.app/profile/thibaultleouay.dev
88+ avatar: /assets/authors/thibault.jpeg
99+publishedAt: 2025-02-26
1010+image: /assets/posts/how-we-build-our-github-action/GitHub.png
1111+tag: engineering
1212+---
1313+1414+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.
1515+1616+There are three ways to build a GitHub Action:
1717+1818+- Composite actions
1919+- Javascript actions
2020+- Docker container actions
2121+2222+2323+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.
2424+This way we could use our CLI to run the tests.
2525+2626+We needed to have a way to pass the API key and the configuration file to the action.
2727+2828+2929+Let's start our speedrun on building our own custom Docker GitHub Action.
3030+3131+### Create a Dockerfile
3232+3333+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.
3434+3535+3636+```Dockerfile
3737+FROM alpine:3.21.3
3838+3939+RUN apk --no-cache add curl
4040+4141+WORKDIR /home/openstatus
4242+4343+COPY entrypoint.sh .
4444+4545+RUN curl -o cli.tar.gz -L https://github.com/openstatusHQ/cli/releases/latest/download/cli_Linux_x86_64.tar.gz
4646+4747+RUN tar -xf ./cli.tar.gz
4848+4949+ENTRYPOINT ["/home/openstatus/entrypoint.sh"]
5050+```
5151+5252+It results in a small image of around 25 MB, which is perfect for a GitHub Action.
5353+5454+To download the latest version of the CLI we use the following URL.
5555+5656+```
5757+https://github.com/openstatusHQ/cli/releases/latest/download/cli_Linux_x86_64.tar.gz
5858+```
5959+6060+6161+Our entrypoint.sh file is also quite simple. We just run the CLI with the API key and the configuration file.
6262+6363+```bash
6464+#!/bin/sh
6565+6666+if [ -z "$INPUT_CONFIG_PATH" ]; then
6767+ /home/openstatus/openstatus run --access-token $INPUT_API_KEY
6868+else
6969+ /home/openstatus/openstatus run --access-token $INPUT_API_KEY --config $INPUT_CONFIG_PATH
7070+fi
7171+7272+if [ $? -eq 0 ]
7373+then
7474+ echo "OpenStatus run successfully"
7575+ exit 0
7676+else
7777+ echo "OpenStatus run failed"
7878+ exit 1
7979+fi
8080+```
8181+8282+### Create the action.yml file
8383+8484+Our action.yml file
8585+8686+```yaml
8787+name: 'OpenStatus Synthetics CI'
8888+description: 'Run your OpenStatus synthetics checks as part of your GitHub Actions workflow.'
8989+author: 'OpenStatus'
9090+branding:
9191+ icon: 'zap'
9292+ color: gray-dark
9393+9494+inputs:
9595+ api_key:
9696+ description: 'OpenStatus API key'
9797+ required: true
9898+ config_path:
9999+ description: 'Path to the OpenStatus configuration file'
100100+ required: false
101101+102102+runs:
103103+ using: docker
104104+ image: docker://ghcr.io/openstatushq/action:latest
105105+ args:
106106+ - ${{ inputs.api_key }}
107107+ - ${{ inputs.config_path }}
108108+```
109109+110110+That's all you need to build your own Docker custom GitHub Action.
111111+112112+113113+114114+I struggle a bit with the GitHub action because the docker image was being built on the fly.
115115+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.
116116+117117+The solution was to change the image in the action.yml file to the image in the GitHub Container Registry.
118118+119119+From:
120120+121121+```yaml
122122+image: Dockerfile
123123+```
124124+To:
125125+```yaml
126126+image: docker://ghcr.io/openstatushq/action:latest
127127+```
128128+129129+### Publish it to the GitHub marketplace
130130+131131+Add branding to your action and your action is ready. You can publish it to the GitHub Marketplace.
132132+133133+134134+### Conclusion
135135+136136+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.
137137+138138+139139+140140+If you want to start using our action you can find it in the GitHub Marketplace.
141141+142142+[https://github.com/marketplace/actions/openstatus-synthetics-ci](https://github.com/marketplace/actions/openstatus-synthetics-ci
143143+)
144144+145145+146146+If you want to see a GitHub repository with the action you can find it here.
147147+148148+[https://github.com/openstatusHQ/github-action-tester/actions](https://github.com/openstatusHQ/github-action-tester/actions
149149+)
150150+151151+152152+_Create an account on [OpenStatus](/app/sign-in?ref=blog-github-action) and start running your own Synthetics Tests in your GitHub Actions._