Matching branch and path not working

This config should build anything that is pushed to the master branch, if it was a file in the folder specified:

name: "Build and Test Frontend"

on:
  push:
    branches:
    - 'master'
    paths:
    - 'frontend/**'
    - '.github/workflows/**'

I have no idea what i’m doing wrong but I cannot for the life of me get this to work. No builds start at all.

Also, does anyone have any tips for testing outside of the master branch? I keep having to commit tests to master to see if this works, and its untidy in the git history.

Looks fine to me. Are you sure that GitHub Actions is enabled on the repository and the workflow file meets the naming requirements?

1 Like

File is called:

> build-and-push-backend-image.yml

I think thats ok.

That should be fine as long as it’s inside the .github/workflows directory. Testing a similar setup on one of my repo’s:

name: "Build and Test Frontend"

on:
  push:
    branches:
    - 'path-check'
    paths:
    - 'frontend/**'
    - '.github/workflows/**'

jobs:
  hello-world:
    runs-on: ubuntu-latest

    steps:
      - name: Hello world
        run: echo Hello world

Makes it run just fine:

So I’m guessing either Actions is disabled on your repository or something else in your workflow file is causing a YAML parse error. Could you share the entire workflow to see if anything else stands out?

1 Like

Thanks @outrunthewolf  for your feedback! Please follow @oldskool 's comment to check your setting&folder structure.

For testing outside of the master branch, you need to create a new branch, and put the workflow file(and its folder structure) in the branch, workflow will execute on the branch then.