Simon Willison: TILs on github-actions

github-actions Conditionally running a second job in a GitHub Actions workflow - 2022-07-11

My simonwillisonblog-backup workflow periodically creates a JSON backup of my blog's PostgreSQL database, using db-to-sqlite and sqlite-diffable. It then commits any changes back to the repo using this pattern: …

github-actions Optimizing PNGs in GitHub Actions using Oxipng - 2022-05-18

My datasette-screenshots repository generates screenshots of Datasette using my shot-scraper tool, for people who need them for articles or similar. …

github-actions GitHub Actions job summaries - 2022-05-17

New feature announced here. Here's the full documentation. …

github-actions Deploying a live Datasette demo when the tests pass - 2022-03-27

I've implemented this pattern a bunch of times now - here's the version I've settled on for my datasette-auth0 plugin repository. …

github-actions Using the GitHub Actions cache with npx and no package.json - 2022-03-22

Some of my repositories have GitHub Actions workflows that execute commands using npx, for example my graphql-scraper repo using npx to install and run the get-graphql-schema tool: …

github-actions Testing against Python 3.11 preview using GitHub Actions - 2022-02-02

I decided to run my CI tests against the Python 3.11 preview, to avoid the problem I had when Python 3.10 came out with a bug that affected Datasette. …

github-actions Storing files in an S3 bucket between GitHub Actions runs - 2021-12-07

For my git-history live demos I needed to store quite large files (~200MB SQLite databases) in between GitHub Actions runs, to avoid having to recreate the entire file from scratch every time. …

github-actions Attaching a generated file to a GitHub release using Actions - 2021-09-07

For Datasette Desktop I wanted to run an action which, when I created a release, would build an asset for that release and then upload and attach it. …

github-actions Installing different PostgreSQL server versions in GitHub Actions - 2021-07-05

The GitHub Actions ubuntu-latest default runner currently includes an installation of PostgreSQL 13. The server is not running by default but you can interact with it like this: …

github-actions Running tests against PostgreSQL in a service container - 2021-02-23

I wanted to run some Django tests - using pytest-django and with Django configured to pick up the DATABASE_URL environment variable via dj-database-url - against a PostgreSQL server running in GitHub Actions. …

github-actions Using Prettier to check JavaScript code style in GitHub Actions - 2020-12-31

I decided to adopt Prettier as the JavaScript code style for Datasette, based on my success with Black for Python code. …

github-actions Talking to a PostgreSQL service container from inside a Docker container - 2020-09-18

I have a Django application which uses PostgreSQL. I build the Django application into its own Docker container, push that built container to the GitHub package registery and then deploy that container to production. …

github-actions Open a debugging shell in GitHub Actions with tmate - 2020-09-14

⚠️ 17 Feb 2022: There have been reports of running tmate causing account suspensions. See this issue for details. Continue with caution. …

github-actions Skipping a GitHub Actions step without failing - 2020-08-22

I wanted to have a GitHub Action step run that might fail, but if it failed the rest of the steps should still execute and the overall run should be treated as a success. …

github-actions Using grep to write tests in CI - 2020-08-19

GitHub Actions workflows fail if any of the steps executes something that returns a non-zero exit code. …

github-actions Updating a Markdown table of contents with a GitHub Action - 2020-07-22

markdown-toc is a Node script that parses a Markdown file and generates a table of contents for it, based on the headings. …

github-actions Running different steps on a schedule - 2020-04-20

Say you have a workflow that runs hourly, but once a day you want the workflow to run slightly differently - without duplicating the entire workflow. …

github-actions Commit a file if it changed - 2020-04-19

This recipe runs a Python script to update a README, then commits it back to the parent repo but only if it has changed: …

github-actions Set environment variables for all steps in a GitHub Action - 2020-04-19

From this example I learned that you can set environment variables such that they will be available in ALL jobs once at the top of a workflow: …

github-actions Dump out all GitHub Actions context - 2020-04-19

Useful for seeing what's available for if: conditions (see context and expression syntax). …

github-actions Only run GitHub Action on push to master / main - 2020-04-19

Spotted in this Cloud Run example: …