Pattern match on Checkout?

I am trying to find a way to perform a simple pattern match on a PR and block merge based on if it matches. Effectively I would like to check the file contents of the PR for a specific string, lets call it foo and then if the foo string is present in the files of the PR then block merge.

Is this possible?

Currently I have

name: My Workflow
on: [push, pull_request]
    runs-on: ubuntu-latest
      EXIT: exit 0

      - uses: actions/checkout@v2
        if: ${{ contains(github.ref , 'foo') }}
          EXIT: exit 1
      - run: ${env:EXIT}

the problem is that actions/checkout@v2 is not even running, as shown here

What you are doing in your workflow is checking to see if the ref contains foo. To get the contents of the PR you will either need to write something against the PR API or checkout the files and do some comparison locally.

1 Like

Github.ref of pull_request event is PR merge branch refs/pull/:prNumber/merge . It will not include ‘foo’.
If you want to check the changed files contents of PR, you could use this API to get changed file list.