While playing with the log analyser I mentioned in my post about building fail2ban rules, I accidentally overwrote the
index.html file for my homepage.
After a bit of digging around and not being able to find a copy of it anywhere (it was probably on my old work laptop, so might be on the backup USB drive in the bottom draw…) I started to write a new one. To make sure I could always find a copy I decided I’d check it into GitHub.
As part of setting up the new repo I thought I’d have a look at the relatively new GitHib Actions that allow you to run jobs on your own hardware.
Actions are GitHubs implementation of a CI pipeline, you can attach an action to any number of events that happen on a repo e.g.
- Post a welcome message when somebody new opens an issue
- Run tests on any new pull requests
- Deploy the project when code is merged into a specific branch
You can find a full list of triggers here.
It’s this last one that I’m going to use a trigger to deploy the new homepage when ever I commit to the master branch.
Actions are defined in a YAML file that you place in the
.github/workflow directory of your repository.
name: PublishHomepage on: [push] jobs: deploy: name: Deploy Homepage runs-on: [self-hosted, linux] steps: - name: Checkout uses: actions/checkout@v2 with: repository: 'hardillb/homepage' path: 'homepage' - run: bash ./homepage/scripts/deploy.sh
This attaches to the
push trigger and asks that it is run on a
linux machine. Where it will checkout the
/hardillb/homepage repository and then execute the
deploy.sh script found in the
scripts directory of the repo.
Github supply runners for Windows/Linux/macOS on a range of architectures including ARM which means I can deploy one on the Raspberry Pi that hosts my website. Details of how to add a Action Runner to your specific project and download the package can be found here.
I went with running my own Action Runner on the same machine as the site is hosted because it means I don’t need to worry about setting up a custom ssh key and storing it as a secret so a cloud runner could access the device and upload the changed files. This way the script runs on the same machine and I can make sure the user has access rights to the right directory to copy the files to.