Understanding Workflow Dispatch in GitHub Actions – A Beginner’s Guide

GitHub Actions is a powerful tool that lets you automate your software development tasks, like building, testing, and deploying your code. But sometimes, you don’t want these tasks to run automatically on every push. What if you want to run a workflow manually whenever you need it?
This is where workflow_dispatch
comes in! Let’s break it down.
What is workflow_dispatch
?
Think of a workflow in GitHub Actions like a recipe. Normally, the recipe might run automatically every time someone pushes code to your repository.
But with workflow_dispatch
, you get a “manual trigger” button. This means you can go to GitHub, click Run workflow, and choose exactly how and when you want it to run.
Why is it useful?
Manual control: Run workflows only when needed (like deploying your app to production).
Custom inputs: You can ask the user for parameters like branch name, microservices to deploy, or environment.
Flexible automation: Combine manual control with automation for advanced workflows.
How to use workflow_dispatch
Here’s a simple example:
name: Deploy-App
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy'
required: true
default: 'main'
deploy-api:
description: 'Deploy API service'
required: true
type: boolean
default: true
Breaking it down:
name: Deploy-App
→ Name of your workflow.on: workflow_dispatch
→ Makes the workflow run manually.inputs:
→ Parameters you can ask the user to provide when triggering the workflow.branch
→ Which branch should we deploy?deploy-api
→ Should we deploy the API service? (true/false)
When a developer clicks Run workflow, they’ll see these inputs in GitHub and can set them as needed.
How it looks in GitHub
When you open your repository:
Go to Actions.
Select your workflow (e.g.,
Deploy-App
).Click Run workflow.
Fill in the inputs, like branch name or checkboxes for services.
Click Run → the workflow starts with the parameters you chose.
Advanced Usage
workflow_dispatch
works perfectly with matrix builds and multi-service deployments.
For example, you can:
Select which microservices to build (microservice-a-api, mircoserivce-b-api).
Choose which markets/regions to deploy (
pak, ind, bang
).Generate unique Docker image tags based on branch name + date + run number.
Automatically push your images to Azure Container Registry (ACR).
Trigger Helm/Flux deployments to update Kubernetes clusters.
All this happens after you click the Run button and provide inputs — giving you total control.
Key Points for Students
workflow_dispatch
= Manual workflow trigger.You can ask for inputs — like a form for your workflow.
Useful for deployments or tasks that shouldn’t run on every push.
Can be combined with matrix strategy to run multiple jobs in parallel.
Perfect for teaching CI/CD because students can see the workflow run step by step after choosing their inputs.
Example Use Case
Imagine you have a microservices app with microservice-a-api and mircoserivce-b-api.
You don’t want to deploy every time you push code.
You want to deploy only when ready, and maybe only microservice-a-api to
uat
first.
Using workflow_dispatch
, you:
Click Run workflow.
Select
branch = uat
.Check only
scan-api
.Workflow builds Docker image → pushes to registry → updates your Kubernetes cluster.
✅ Control is yours!
Conclusion
workflow_dispatch
is like having a start button for your automation.
Developers can trigger workflows on demand.
Inputs make workflows dynamic and flexible.
Perfect for deployments, testing, or advanced automation pipelines.
Subscribe to my newsletter
Read articles from Muhammad Sufiyan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Muhammad Sufiyan
Muhammad Sufiyan
As a former 3D Animator with more than 12 years of experience, I have always been fascinated by the intersection of technology and creativity. That's why I recently shifted my career towards MERN stack development and software engineering, where I have been serving since 2021. With my background in 3D animation, I bring a unique perspective to software development, combining creativity and technical expertise to build innovative and visually engaging applications. I have a passion for learning and staying up-to-date with the latest technologies and best practices, and I enjoy collaborating with cross-functional teams to solve complex problems and create seamless user experiences. In my current role as a MERN stack developer, I have been responsible for developing and implementing web applications using MongoDB, Express, React, and Node.js. I have also gained experience in Agile development methodologies, version control with Git, and cloud-based deployment using platforms like Heroku and AWS. I am committed to delivering high-quality work that meets the needs of both clients and end-users, and I am always seeking new challenges and opportunities to grow both personally and professionally.