Skip to content

How to trigger a GitHub action for a branch OR changes to a path? #26770

Answered by theory
theory asked this question in Actions
Discussion options

You must be logged in to vote

Actually, it turns out this wasn’t working as I thought. It in fact needs to be:

name: 🐘 Postgres
on: [push, pull_request]
jobs:
  filter:
    name: 🔎 Detect Postgres Changes
    runs-on: ubuntu-latest
    outputs:
      pg: ${{ steps.filter.outputs.pg }}
    steps:
      - uses: actions/checkout@v2
      - uses: dorny/paths-filter@v2
        id: filter
        with: { filters: '{ pg: [ "**/pg.*", "**Engine**" ] }' }
  Postgres:
    # Run only on develop or main, or when a pg file has changed in the branch.
    needs: filter
    if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || needs.filter.outputs.pg == 'true'
    # ....

Which means it must always run, even on…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant