a collection of stuff and things

From PHP to Python and GitHub Actions

Some time ago for a bit of fun I had created Horo Football - a twitter account that auto-tweeted (via a php script and cron job) some randomly generated horoscopes from a football context.

Having dabbled with a bit of python recently, I decided to rewrite this in python.

becomes

I am amazed at how concise python is, having switched from a 200 line php file with a few methods coded in different classes so around 250 all in, to around 180 in python, but with processing (excluding the arrays of data) to around 25 lines.

You can see outputs published via a GitHub action to a README.md file in this repo

As you can see from the action it is essentially a set of key-value pairs in yaml. Installing Python and any dependencies in a serverless environment - managed by GitHub, the Python script updates the README file and this action commits it.

workflow_dispatch means it can be run manually, schedule takes a cron expression. It can also be triggered on a push or pull request.

GitHub actions are stored in your repository in a .github/workflows folder and thats it.

Published 5 September 2020, with 210 words.