DEV Community

Cover image for Manual Trigger on Github action - #2
Hidayt Rahman
Hidayt Rahman

Posted on

Manual Trigger on Github action - #2

Intro

In the Github action session, In this article we will be learning about Manual Trigger action for the specific task.

Why we need this?
We often require some short of actions that we only do when we need any specific action.
For example, you wanna release your app from dev env to qa env after fixing a new bug.
In this case we can use Manual trigger that will deploy app from dev to qa once we trigger the action.

Also Read
In the last article We learnt Greet on first PR and Issue

How can we do that?
We can achieve the manual trigger feature using Workflow Dispatch It enables a workflow to be triggered manually, you need to configure the workflow_dispatch event. You can manually trigger a workflow run using the GitHub API, GitHub CLI, or GitHub browser interface

Lets create a brand new workflow under the .github/workflows/manualTrigger.yml

Paste the below code and push your changes to the main branch.

name: "Workflow Manual Trigger"

on: 
  workflow_dispatch:
    inputs:
      author:
       description: 'Choose author'
       required: true
       type: choice
       options:
                - admin
                - editor
                - contributor
      location:
        description: 'Choose Location'     
        required: true
        default: 'in'
        options:
                - us
                - uk
                - in



jobs:
  printInputs:
    runs-on: ubuntu-latest
    steps:
    - run: |
        echo "Author : ${{ github.event.inputs.author }}"
        echo "Location : ${{ github.event.inputs.location }}" 
Enter fullscreen mode Exit fullscreen mode

Now go the actions tab and select Workflow Manual Trigger

Click on the Run Workflow button

Run workflow image

Choose the fields.

Opened workflow image

After selecting the specific field click on green Run workflow button

It will start running the workflow. Once done you can verify the actions while opening the logs.

Action logs

You can see we have the selected data in the logs.

Feel free to utilise the action based on your requirement.

Happy Action!

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay