Github workflow not running on pull_request despite matching the branch?

In one of my repos, I have set up github actions to run a testing workflow on every push that touches python files, and on every pull request to the default branch:

on:
  push:
    paths:
      '**.py'
  pull_request:
    branches: [ $default-branch ]

I have code coverage set up for branch protection. For one PR which touches only documentation files, the workflow didn’t get triggered, so codecov never gets the data to give the okay to merge.

I expected my workflow to run on this, because it’s a pull request to the default branch, master. It doesn’t. How do I change my workflow to run on a pull request like this one? Alternatively, how do I stop codecov from blocking pull requests that only update documentation?

You need to write the actual branch name in the branches filter list. The $default-branch thing is for templates only. So this should work:

  pull_request:
    branches:
      - master