Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 6

repository_dispatch not triggering actions

Solved! Go to Solution.

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_dispatc...) 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 :(

5 Replies
Highlighted
Solution
Copilot Lvl 3
Message 2 of 6

Re: repository_dispatch not triggering actions

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

Highlighted
Copilot Lvl 3
Message 3 of 6

Re: repository_dispatch not triggering actions

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

 

That's sad!

Highlighted
Ground Controller Lvl 1
Message 4 of 6

Re: repository_dispatch not triggering actions

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 }}
Highlighted
Ground Controller Lvl 1
Message 5 of 6

Re: repository_dispatch not triggering actions

Highlighted
Copilot Lvl 3
Message 6 of 6

Re: repository_dispatch not triggering actions

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?