repository_dispatch not triggering actions

I do have a separate branch where I’m currently playing around with actions. Since I need to trigger actions externally I wanted to make use of the repository_dispatch event (https://help.github.com/en/articles/events-that-trigger-workflows#external-events-repository_dispatch) which seems to be right choice - but sadly I can’t get it to work.

My workflow.yml:

name: Update blog

on: [push, repository_dispatch]

jobs:
update:
runs-on: ubuntu-latest
steps:
-uses: actions/checkout@v1
[...]

When I try the following cURL I get the proper 204 response:

curl -v -X POST -u "nehalist:<token>" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" --data '{"event_type":"update"}' https://api.github.com/repos/nehalist/<reponame>/dispatches

But the action is not triggered.

I really need to trigger actions from external - anyone can help me in this regard? I’ve ran out of ideas :frowning:

2 Likes

Definitely something missing from the docs: the repository_dispatch only triggers on the master branch.

11 Likes

Which makes it useless for anything branch related. So most of the CI related things :confused:

That’s sad!

7 Likes

While I agree this is uselss and very annoying. It is annoying because you must pollute and directly work on this CI command in master to test and develop… It can still benefit you because you can checkout certain branches on any given CI command:

# Name is optional and if present must be used
# in the url path for badges
name: Docs Build and Deploy Firebase

on:
  # ONLY triggers on master branch
  repository_dispatch:
    types: [dev-docs-build, master-docs-build]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Test Echo 1
        run: echo "test echo"
  # Build the site and deploy docs when the have been updated
  devDocsBuild:
    runs-on: ubuntu-latest
    steps:
      - name: Test Echo 2
        run: echo "test echo"
      - uses: actions/checkout@v2
        with:
          # hardcoded ci-test branch ref
          ref: ci-test
      - run: echo ${{ github.event.client_payload.sha }}

  # Build the site and deploy docs when the have been updated
  master-docs-build:
    runs-on: ubuntu-latest
    steps:
      - name: Test Echo 3
        run: echo "test echo"
      - uses: actions/checkout@master
        with:
         # dynamic ref passed from action. either dev or master
          ref: ${{ github.event.client_payload.ref }}
      - run: echo ${{ github.event.client_payload.sha }}
1 Like

Check out the checkout action docs: https://github.com/actions/checkout#Checkout-a-different-branch

1 Like

I was planning to put my docker image qualification into a workflow that I could call from either a pull request or on a release; neither of which would execute from master.  Is there another way to trigger a workflow from another workflow on a pull request or release (tag-based href) build?

This limitation effectively means that we can only use a single branch - master - for releases.

Our use-case requires commits to one repository to trigger builds in another repository, and repository_dispatch seems to fit the bill. Since we have release branches - i.e. 3.7.x, 3.8.x - these cannot be triggered via repository_dispatch events, which is a pretty big deal for us. Our options are to either combine multiple repositories into a single one (a significant amount of work), or trigger an action from a remote repository that would in turn trigger the workflow.

Why do repository_dispatch events have this artificial & severe limitation?

1 Like

Has there been any progress on this?

We touched on this GitHub Actions aspect today and are starting to consider other alternatives to GitHub Actions. In other words, this limitation is a pretty big deal for us.

GitHub actions token has a restriction that means it cannot trigger workflows.

You need to use a service account personal access token to dispatch the event. The workflow will then run, as long as you include a ref to checkout in your event, you can then checkout any branch.

I think most people here are hitting if you use GITHUB_TOKEN it will not trigger workflows