Finish and publish statuspage post

Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
Harsh Shandilya 2020-02-07 20:38:57 +05:30
parent ca93cc9493
commit 3a5c165d70
1 changed files with 50 additions and 2 deletions

View File

@ -1,7 +1,6 @@
+++
categories = ["webdev"]
date = 2020-02-05T10:39:26+05:30
draft = true
slug = "creating-a-continuously-deploying-static-statuspage-with-github"
tags = ["webdev", "github actions", "github pages"]
title = "Creating a continuously deploying static statuspage with GitHub"
@ -28,4 +27,53 @@ For hobbyist projects without any real budget (like this site and the couple oth
![CNAME file in repository](/uploads/statuspage_cname_file.png)
- Finally, time to start creating our workflow for GitHub Actions. A quick glance at the static_status README will inform you about the `config` file that it uses to configure itself, and status_hostname_list.txt which has a list of all services it needs to check. `config` is easy to understand and modify, so I'll skip it (you can diff [mine](https://github.com/msfjarvis/status.msfjarvis.dev/blob/master/config) with upstream and use the changes to educate yourself should the need arise). Instead, I'll cover the `status_hostname_list.txt` file that gave me grief when I was setting this up.
- A quick glance at the static_status README will inform you about the `config` file that it uses to configure itself, and status_hostname_list.txt which has a list of all services it needs to check. `config` is easy to understand and modify, so I'll skip it (you can diff [mine](https://github.com/msfjarvis/status.msfjarvis.dev/blob/master/config) with upstream and use the changes to educate yourself should the need arise). This part should be very straightforward, though I did encounter a problem where using `ping` as the detection mechanism caused sites to falsely report as down. Switching to `curl` resolved the issue.
- Finally, time to add the automation to this whole thing. Any CI solution with a cron/schedule option will work, I used GitHub Actions, you don't have to. I set a schedule of once every 30 minutes, depending on what platform you're using for CD and what services you're hosting, you might want to choose a shorter period. Here's my GitHub Actions workflow.
```yaml
name: "Update status page"
on:
schedule:
- cron: "*/30 * * * *"
push:
jobs:
update-status-page:
runs-on: ubuntu-latest
steps:
- name: Install traceroute
run: sudo apt-get install traceroute -y
- name: Checkout config
uses: actions/checkout@v2
- name: Checkout static_status
uses: actions/checkout@v2
with:
repository: Cyclenerd/static_status
path: static_status
clean: false
- name: Generate status page
run: |
mkdir -p static_status/status/
cp config static_status/
cp status_hostname_list.txt static_status/
cp CNAME static_status/status/
cd static_status/
rm status_maintenance_text.txt
./status.sh
- name: Deploy
uses: peaceiris/actions-gh-pages@v2
env:
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./static_status/status
SCRIPT_MODE: true
with:
username: "MSF-Jarvis"
useremail: "msfjarvis+github_alt@gmail.com"
```
This installs `traceroute` which is needed by static_status, checks out my repository, clones static_status to the static_status directory, copies over config and hostname list to that folder, places the `CNAME` file in the static_status/status directory, runs the script to generate the status page, and finally publishes the static_status/status folder to the `gh-pages` branch, as my bot account.
The result of this is a simple and fast statuspage that can be hosted anywhere by simply coping the single `index.html` over. If you have a separate server to run this off, you can get away with replacing this entire process with a single crontab command. Being a bash script lets static_status run on essentially any Linux-based platform so you can actually deploy this from a Raspberry Pi with no effort. Hope this helps you to create your own status pages!