23

I created the workflow Test but there is no Run workflow button to run it manually.

enter image description here

This is my test.yml file. Is there anything missing?

name: Test

on:
  release:
    types: [created]
  
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Run a one-line script
        run: echo Hello, world!
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129

3 Answers3

54

Some workflows, such as those, based on workflow_dispatch event, the workflow will not even show until the code is on the main (or default branch).

The good news is, once you do merge your feature to main, you may keep on working on the feature branch. From then on, you will have the option to choose which branch you want to run the workflow on , like in the picture.

select workflow config based on branch

theannouncer
  • 1,148
  • 16
  • 28
DBencz
  • 849
  • 1
  • 9
  • 15
  • Is there anyways to run workflow from github rest api? , Note: this is not a re run job, I need for run workflow. – microset Nov 09 '22 at 06:47
  • I got solution for this questions https://stackoverflow.com/questions/70151645/how-to-trigger-a-workflow-dispatch-from-github-api – microset Nov 09 '22 at 06:49
  • I tried microset's solution but `gh workflow list` only showed the workflows I can already run via GH, not the new workflow_dispatch that isn't on the main branch. – AdamC Mar 29 '23 at 14:42
21

You need to put workflow_dispatch: under on:.

name: Test

on:
  release:
    types: [created]
  workflow_dispatch: # Put here!!
  
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Run a one-line script
        run: echo Hello, world!

Then, a Run workflow button is shown.

enter image description here

enter image description here

It's ok to put workflow_dispatch: before release:. It works as well.

name: Test

on:
  workflow_dispatch: # Putting here is also fine!!
  release:
    types: [created]
  
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Run a one-line script
        run: echo Hello, world!
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
6
on:
  workflow_dispatch: {}
  push:
    branches:
      - 'feature/name-of-feature-branch'

Trigger workflow on push and define your branch under branches:. When your development is done and ready to merge main remove unnecessary code.

on:
  workflow_dispatch: {}
Antti
  • 155
  • 4
  • 17