DEV Community

Amaresh Pelleti
Amaresh Pelleti

Posted on Originally published at devtoolhub.com

Trigger a Workflow From Another Workflow: 4 Ways Tested

Originally published on DevToolHub.

To trigger a workflow from another workflow, do not count on events that GITHUB_TOKEN creates. A push, a release or an issue made with it starts nothing, and GitHub shows no error. Four things do work: a reusable workflow, workflow_dispatch or repository_dispatch, a workflow_run listener, and a token that is not GITHUB_TOKEN.

I tested each option on 25 November 2026 in a private throwaway repository, on GitHub-hosted ubuntu-latest runners. The run counts below are real. The last section lists what I did not test.

In this guide:

  • See which events GITHUB_TOKEN starts and which it silently drops
  • Pick between workflow_call, workflow_dispatch, repository_dispatch and workflow_run
  • Set the exact token permissions each one needs
  • Avoid the gotchas, including a step that shows green after it failed

Why can't GITHUB_TOKEN trigger a workflow from another workflow?

GitHub blocks it on purpose, to stop a workflow from starting itself in a loop. The docs say that events created with the repository's GITHUB_TOKEN do not start new runs, with a few exceptions. So a release workflow that publishes with GITHUB_TOKEN never starts your on: release workflow.

I wrote one producer workflow that ran with GITHUB_TOKEN and did six things: pushed a branch, created a release, opened an issue, opened a pull request, started a workflow and sent a repository_dispatch. Then I wrote one listener workflow per event. After that I repeated the push, release, issue and pull request from my own gh login.

Event Created with GITHUB_TOKEN Created with my own login
Push to a branch No run Run
Release published No run Run
Issue opened No run Run
Pull request opened Run, but waiting for approval Run

The first three never started a listener. The pull request case is newer behaviour. I come back to it in the gotchas.

How do you trigger a workflow from another workflow with dispatch events?

Call the API from the first workflow. Events of type workflow_dispatch and repository_dispatch always create runs, even when GITHUB_TOKEN sends them. In my test both listeners ran, and the actor on both runs was github-actions[bot].

For example, here is the dispatch step I ran, with the file name changed:

permissions:
  contents: read
  actions: write
steps:
  - run: gh workflow run publish.yml --ref main
    env:
      GH_TOKEN: ${{ github.token }}
Enter fullscreen mode Exit fullscreen mode

But the two events need different permissions, and the errors do not say which. I ran each call with one permission at a time:

Token permission gh workflow run repository_dispatch
contents: read only HTTP 403: Resource not accessible by integration 403
actions: write only Fails on the default branch lookup 403
contents: write only 403 Accepted, no error
actions: write with --ref main Worked Not run

Tip: gh workflow run first looks up the default branch, which needs contents: read. With only actions: write it fails with unable to determine default branch. Pass --ref main and it works.

So workflow_dispatch needs actions: write, and repository_dispatch needs contents: write. The second call looked like this:

gh api "repos/$GITHUB_REPOSITORY/dispatches" -f event_type=release-created
Enter fullscreen mode Exit fullscreen mode

The listener subscribes with repository_dispatch: types: [release-created]. I used a different event name in the test, chain-test, but the call is the same.

How can you trigger a workflow from another workflow without dispatch?

Without any API call, use workflow_call when the second job must run right after the first, in the same run. Use workflow_run when it must run after a workflow you do not control or after one that ends in several ways. Neither needs a special token.

A reusable workflow runs inside the caller's run, so it is the simplest option. In my test the called job logged the same run ID as the producer, and it needed no trigger at all:

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - run: echo "build and release here"
  publish:
    needs: release
    uses: ./.github/workflows/publish.yml
Enter fullscreen mode Exit fullscreen mode

The called file declares on: workflow_call:. The reusable workflows docs cover inputs and secrets.

A workflow_run listener starts after another workflow finishes. This is the shape I tested:

on:
  workflow_run:
    workflows: ['Release']
    types: [completed]
Enter fullscreen mode Exit fullscreen mode

It fired after the producer completed. Its actor was me, the person who started the producer. There is a catch: when the upstream run was itself started by a GITHUB_TOKEN dispatch, the listener never fired, in two tries. Started by my own login, the same upstream workflow did trigger it. According to the events reference, workflow_run chains at most three levels deep. If A triggers B, and so on up to F, then E and F do not run.

Warning: A workflow_run workflow gets secrets and a write token even when the first workflow had none. Never check out and run code from a pull request in it. The docs warn about cache poisoning and pwn requests.

Should you use a personal access token or a GitHub App token?

A token that is not GITHUB_TOKEN is the fourth way. Use one when the second workflow has to start from a real event, such as release: published or push, and you cannot change it to workflow_dispatch. The docs say events created with a GitHub App installation token or a personal access token do start workflows.

My own gh login stands in for a personal token here. Everything I created with it started a listener at once, with my account as the actor. I did not create a token, store a secret or build a GitHub App. So I did not test the secret-based setup, only the behaviour of events that come from a user credential.

The trade-off is real. A personal token is tied to one person's account. A GitHub App token needs an app, its ID and a private key stored as secrets. If you can use workflow_call or workflow_dispatch, that is simpler and safer. See the GitHub Actions security guide before you add either token.

Which gotchas will you hit when you trigger a workflow from another workflow?

Five things cost me time.

A green step can hide a failed command. My pull request step had continue-on-error: true. With the setting off, gh pr create printed GraphQL: GitHub Actions is not permitted to create or approve pull requests. The step still showed success, because the step conclusion hides the failure when continue-on-error is set. The setting is under the repository's Actions permissions.

Pull requests from GITHUB_TOKEN wait for approval. After I enabled that setting, the pull request was created by app/github-actions. Both pull_request workflows in the repository got a run with the conclusion action_required. Per the docs, a user with write access has to approve them. I did not click approve.

The on filters still apply. My push listener only watched chain/** branches. A listener that watches main never sees a push to another branch, so test with the real filter.

You cannot chain through GITHUB_TOKEN. I set up A (started by me), B (dispatched by A with GITHUB_TOKEN) and C (workflow_run on B). C never ran, in two tries, while the same listener on a run I had started myself fired at once. workflow_run is not on the list of exceptions, so a run created by GITHUB_TOKEN is a dead end for it.

workflow_run depends on the default branch. Per the events reference, it runs from the workflow file on the default branch. Test it after you merge, not on a feature branch.

For the release side of this, see the guide to automating GitHub releases. The GitHub Actions guide links the rest of the series.

What I did not test

I ran everything in one private repository on GitHub-hosted runners. I did not test a personal access token or GitHub App token stored as a secret, actions/create-github-app-token, self-hosted runners, organization-level workflow permissions, or a workflow_run chain of more than one level that starts from a person. Nor did I approve the waiting pull request runs, pass inputs to a dispatched workflow, or test schedule or check_suite events. GitHub changes these rules from time to time, so check the docs for your case.

Frequently Asked Questions

Q: Why does GITHUB_TOKEN not trigger another workflow?
A: GitHub blocks it to prevent recursive runs. Events created with GITHUB_TOKEN do not start new workflow runs, except workflow_dispatch and repository_dispatch. A pull request created with it starts runs that wait for approval.

Q: How do I trigger a workflow from another workflow in GitHub Actions?
A: Use a reusable workflow with workflow_call to run it in the same run. Or send a workflow_dispatch or repository_dispatch, or listen with workflow_run. All four worked in my test, but workflow_run only after a run that did not come from GITHUB_TOKEN.

Q: What permissions does gh workflow run need in a workflow?
A: actions: write, plus contents: read for the default branch lookup. Or pass --ref main and skip the lookup. repository_dispatch needs contents: write instead.

Q: Does workflow_run work with GITHUB_TOKEN?
A: Only partly. After a run I started myself, it fired. After a run that GITHUB_TOKEN had dispatched, it did not, in two tries. Also, it chains three levels at most, and it runs with secrets, so never run untrusted pull request code in it.

Quick Summary:

  • Events created with GITHUB_TOKEN start no workflows, except workflow_dispatch, repository_dispatch and (with an approval step) pull requests
  • In my test a push, a release and an issue made with GITHUB_TOKEN started 0 listeners, and the same actions with my own login started all three
  • workflow_dispatch needs actions: write and repository_dispatch needs contents: write
  • gh workflow run needs --ref or contents: read, or it cannot find the default branch
  • workflow_call runs inside the caller's run, and workflow_run chains three levels at most and did not fire after a run that GITHUB_TOKEN had dispatched
  • A continue-on-error step shows green even when its command failed

To trigger a workflow from another workflow, try workflow_call first, then workflow_dispatch, and use a personal or App token only when the event itself must come from a real push or release.

Top comments (0)