Updating my profile README with GitHub Actions
Having heard of GitHub’s new profile README feature—and seeing many fun and clever takes on its functionality—I decided to take a shot at simple README showing something I like, backed up by a simple GitHub Action that keeps the content updated throughout the day. Having used self-hosted CI/CD tools like Drone to automatically deploy configurations and code in the past, this seemed like an easy introduction to GitHub’s own take on CI/CD.
For the content I chose a framegrab from my webcam at Gibraltar Peak here in Santa Barbara. Some friends and I rent some tower space on this peak for a small community internet project and have placed a cheap IP camera facing west to catch the daily sunset—and peek above the clouds when the marine layer makes an appearance.
On a server at the peak I have
ffmpeg pulling in the RTSP feed and grabbing a single frame, resizing it, and saving it to a publicly-accessibly URL:
#!/bin/bash /usr/local/bin/ffmpeg -y -i "rtsp://<camera_ip_and_port>/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif" -vframes 1 -s 1280x720 /<web_root>/m/frame.jpg
An entry in the crontab runs the above script every minute.
This is near as simple as a README.md can get:
!(https://raw.githubusercontent.com/raylas/raylas/master/frame.jpg) `Updated-every-five-minutes frame from my webcam on Gibraltar Peak in Santa Barbara, California.`
Note that I’ve linked to the raw repository URL of
Coming from using Drone and its YAML syntax, defining my new action felt pretty familiar.
Using the supported schedule trigger, the action below performs the following every five minutes:
- Checks out the repository using GitHub’s first-party checkout action
- Grabs the latest framegrab from our web server
git diffdetects a change, the new
frame.jpgis committed and pushed to the master branch
name: frame-update on: push: workflow_dispatch: schedule: - cron: '*/5 * * * *' jobs: update: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Grab latest stream frame uses: wei/wget@v1 with: args: https://internetmountain.org/m/frame.jpg -O frame.jpg - name: Commit and push run: |- git diff git config --global user.email "email@example.com" git config --global user.name "README-bot" git diff --quiet || (git add frame.jpg && git commit -m "Update stream frame") git push
I came away from this little tangent of a project amazed by how extensible and capable GitHub actions are. Considering that public repositories get unlimited minutes of actions, I will be spending many spare brain cycles on new ideas of how to make Actions do something fun and useful, even if slightly unnecessary…
My GitHub profile repository is here: