Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow filtering on all event types #43

Closed
rexfleischer opened this issue Oct 15, 2020 · 4 comments · Fixed by #44
Closed

allow filtering on all event types #43

rexfleischer opened this issue Oct 15, 2020 · 4 comments · Fixed by #44

Comments

@rexfleischer
Copy link

It would be useful if this could filter based on changes to HEAD. I've ran into patterns where I want to send dispatches to start other workflows for syncing translations or uploading changed assets. But those jobs cannot use this because it gets the error: This action can be triggered only by pull_request or push event

Thanks for the work!

@dorny
Copy link
Owner

dorny commented Oct 15, 2020

I'm not exactly sure what do you mean by changes to HEAD.

Anyway I could make it work for any event the same way as it currently works for push events:

  • For feature branches changes would be detected against the merge-base with base branch
  • For change detection since previous push you could pass the "before" commit SHA using workflow_dispatch inputs and use it as a base parameter for this action.
  • As a fallback if there is no base branch or SHA of previously pushed commit, it would consider only changes in the last commit

Would this work for you?

@rexfleischer
Copy link
Author

yea. that'd be awesome. and all those sound really useful as well (especially the before commit one).

for more context on what I'm trying to do. I'm starting to split out workflows because the jobs are getting really large. I'm sending a couple repository dispatch events every time a merge happens to master. So, I really just want to check for changes on the last commit on the current branch that is checked out. sorry, it's been a long day so I hope I'm still making sense :)

@dorny
Copy link
Owner

dorny commented Oct 16, 2020

Ok, so the idea is clear now. Implementing the changes should be quite easy. I plan to do it later today.

@dorny
Copy link
Owner

dorny commented Oct 16, 2020

Should work now. I tested it with example bellow.
Please reopen this issue if you will still run into some issues.

Thanks for the work!

Consider starring the repo :)

Example:

First workflow which triggers the second one:

name: "Dispatch"
on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Invoke workflow with inputs
      uses: benc-uk/workflow-dispatch@v1
      with:
        workflow: PostBuild
        token: ${{ secrets.PERSONAL_TOKEN }}
        inputs: '{ "before": "${{ github.event.before }}" }'

Follow up workflow:

name: "PostBuild"
on:
  workflow_dispatch:
    inputs:
      before:
        description: 'SHA of last previously pushed commit'
        required: true

jobs:
  post-build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: dorny/paths-filter@v2
      id: filter
      with:
        base: ${{ github.event.inputs.before }}
        filters: ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants