Kent Shikama
Kent Shikama

Reputation: 4060

How do I trigger a Github action if a file is not touched?

I would like to trigger a Github action if the Pipfile is not touched.

I can do something like

on:
  push:
    branches:
      - master
    paths-ignore:
      - Pipfile*

but if a PR touches the Pipfile along with another non-Pipfile file, then the action triggers.

Is this possible?

Upvotes: 1

Views: 615

Answers (1)

Krzysztof Madej
Krzysztof Madej

Reputation: 40849

Two files: Pipfile and foo.py. If only foo.py is modified, then action triggers. If only Pipfile is modified, then action doesn't trigger. If both foo.py and Pipfile is modified, then action doesn't trigger

This is not possible, but what you need is actually a check step to see what file was changed and then exit workflow if Pipfile was changed. You can do this using this command

git diff-tree --no-commit-id --name-only -r ${{ github.sha }}

Upvotes: 1

Related Questions