HomeAbout MeContact Me
Test GitHub Actions workflows on a branch before merging
Development
Test GitHub Actions workflows on a branch before merging
Emanuele Papa
Emanuele Papa
December 29, 2025
2 min

If you’re developing a new GitHub Actions workflow, you may want to test it on a feature branch before merging it into your default branch. Unfortunately, GitHub Actions has a limitation: workflows that only exist on a branch and use workflow_dispatch cannot be triggered until GitHub has “seen” them at least once.

In this guide, we’ll walk through a simple and reliable workaround to test GitHub Actions workflows on a branch using a temporary push trigger and the GitHub CLI.

📝 Prerequisites

Before starting, make sure you have:

  • A GitHub repository with Actions enabled
  • A feature branch where you’re developing the workflow
  • GitHub CLI (gh) installed and authenticated
  • Basic familiarity with GitHub Actions YAML syntax

🛠️ Step-by-step: Testing a GitHub Actions workflow on a branch

1. Create a skeleton workflow triggered by push

On your feature branch, create a new workflow file under .github/workflows/, starting with a minimal trigger using push:

on:
push:

At this stage, the job can be incomplete or just a placeholder. The important part is that the workflow runs at least once. Push the branch to GitHub so the workflow is executed.

💡 You can cancel the job immediately if you don’t want it to finish.

2. Let GitHub register the workflow

Once the workflow has run a single time, GitHub internally registers it. This is a key step: without it, GitHub won’t allow manual triggers from branches. After the first run, you no longer need the push trigger.

3. Replace push with workflow_dispatch

Now update the workflow to use workflow_dispatch:

on:
workflow_dispatch:

Push the updated workflow to the same branch. Even though the workflow no longer triggers automatically, GitHub still recognizes it.

4. Trigger the workflow using GitHub CLI

You can now manually run the workflow directly from your branch using the GitHub CLI:

gh workflow run <workflow-file-name>.yaml -r <branch-name>

This allows you to:

  • Test the workflow repeatedly
  • Iterate quickly without touching the default branch

5. Continue developing and testing

As long as the workflow file remains in the branch, you can keep triggering it via gh until it’s fully tested and ready to be merged. No additional push runs are required.

✅ Conclusion

Testing GitHub Actions workflows on feature branches can be tricky due to current platform limitations. By temporarily enabling a push trigger, letting the workflow run once, and then switching to workflow_dispatch, you can safely and effectively test your workflow without polluting your default branch. Until GitHub provides better native support for branch-only manual workflows, this workaround is one of the cleanest and most practical solutions available.

You can read more in this GitHub discussion.

Happy automating 🚀


Tags

Share


Previous Article
How to change Proxmox IP address when moving to a different network
Emanuele Papa

Emanuele Papa

Android Developer

Table Of Contents

1
📝 Prerequisites
2
🛠️ Step-by-step: Testing a GitHub Actions workflow on a branch
3
✅ Conclusion

Related Posts

Flutter Padding widgets generator with Paddinger
Flutter Padding widgets generator with Paddinger
May 16, 2021
1 min

Quick Links

HomeAbout MeContact MeRSS Feed

Social Media