What happened to github.event.head_commit.modified?

Out of the box, GitHub Actions makes it possible to run workflows conditionally on the modification of a path:

on: push: paths: -'foo/\*\*/\*'

I have the vague memory that there was a time where github.event.head_commit.modified resolved to an array of modified paths. Which would allow:

jobs:
  job1:
    if: contains(github.event.head_commit.modified, 'foo/package.json')
    ...
steps:
- if: contains(github.event.head_commit.modified, 'foo/bar/package.json')

I created a simple action that queries the /repos/:owner/:repo/commits/:ref endpoint and determines whether a path was modified.

It’s easy enough to use that action to impose conditions on running a step, but I would like to put conditions on jobs inside a workflow. Since there is a steps, but not a jobs context, this is not straightforward. Any idea of how I could achieve this result?

That attribute was removed. See the blog post here.

I don’t know how to add to properties in the job context of the current workflow, but what you could do is trigger a repository_dispatch event and send whatever context you need to a second workflow. This could include the output of your action. Then it would be available immediately and useable via job conditions in the second workflow. This action might help if you want to try that idea.

2 Likes

Very nice, thanks. I’ll let others chip in but this seems an appropriate workaround.