On GitHub Actions, how do I run a job if a specific file in a specific branch has been pushed to?

Viewed 627

On GitHub Actions, how do I run a job if a specific file in a specific branch has been pushed to?

I've used the following workflow, but I don't know how to specify a specific branch for that file (such as the main branch):

on:
  push:
    paths: [ index.js ]

Thanks for the help! :)

1 Answers

I have this running with.

Then it's only runs on push with changes in .github/workflows/BranchAndPath.yml and README.md

name: Branch & Path

on:  
  push:
    branches:
      - "**"
    paths: 
      - '.github/workflows/BranchAndPath.yml'
      - 'README.md'
Related