0

In a repository we have :

  1. a workflow that runs on: pull_request so it runs each time I open/ commit to the pull-request (which I opened)

  2. we have an action (runs manually) that commits to the pull-request (updating some files in the branch)

when the second action finishes to run, I can see its commit on the pull request but it doesn't trigger the first workflow to run again (in order to run the workflow after the action's commit, I need each time to insert a dummy commit or close and re-open the pull-request) Is there another way to trigger the first workflow after a "bot" from the 2nd github action commits?

torek
  • 448,244
  • 59
  • 642
  • 775
Sh.F
  • 11
  • 3

2 Answers2

0

You could add push trigger as well to the workflow as follows:

on:
  - push
  - pull_request

It should then run the workflow when you push a commit or tag. See docs here.

unixia
  • 4,102
  • 1
  • 19
  • 23
  • currently my `on:` section is `push: branches: - master pull_request:` because we need it to run on every push to the master, how could I tell it that we want it to run on every push to `current branch` too?! – Sh.F Sep 07 '22 at 13:02
  • what if you removed branches section altogether to let it run on all branches? Will that help your situation? – unixia Sep 08 '22 at 03:49
  • unfortunately no – Sh.F Sep 08 '22 at 11:58
0

Don't do that. GitHub generally "dislike" having workflows trigger other workflows, for the obvious reason.1 Instead, write a reusable workflow, then use and re-use it.

See also Github Actions - trigger another action after one action is completed.


1If the reason isn't obvious, see this question. Follow the link until it becomes obvious why this is a bad idea. (In Computer Science, see the definition of recursion. In Philosophy, a closely related idea is called Begging the Question.)

torek
  • 448,244
  • 59
  • 642
  • 775
  • Thanks for answering, I tried that but unfortunately it doesn't help I want to run the main workflow to see that the pull request is ready. I have on the main workflow a: `push: branches: - master pull_request:` I need a way to add the current_branch to branches list (if there is one) – Sh.F Sep 08 '22 at 11:57
  • Reusable workflows take parameters: have the main workflow pass a parameter that says "main workflow on master" and have the pull request workflow pass a parameter that says "PR workflow on " (filling in the branch part) and have the reusable workflow use the *parameter*. – torek Sep 08 '22 at 16:19