Workflow is not shown so I cannot run it manually (Github Actions)
Asked Answered
L

3

37

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!
Love answered 13/5, 2021 at 17:50 Comment(0)
L
32

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!
Love answered 13/5, 2021 at 17:50 Comment(4)
This is the clearest answerFacer
I agree with @EatatJoes. This answer shows exactly what to do. This should be the accepted answer.Multiplicate
I've put it but still don't have the Run workflow button. What might be the reason?Sukey
@Sukey the change has to be merged to your default branch before the button apperas.Keverne
C
74

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

Chromatology answered 10/3, 2022 at 11:57 Comment(3)
Is there anyways to run workflow from github rest api? , Note: this is not a re run job, I need for run workflow.Goner
I got solution for this questions #70152145Goner
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.Knack
L
32

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!
Love answered 13/5, 2021 at 17:50 Comment(4)
This is the clearest answerFacer
I agree with @EatatJoes. This answer shows exactly what to do. This should be the accepted answer.Multiplicate
I've put it but still don't have the Run workflow button. What might be the reason?Sukey
@Sukey the change has to be merged to your default branch before the button apperas.Keverne
L
13
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: {}
Lotson answered 2/6, 2022 at 8:9 Comment(1)
This should be the accepted answer IMOCramoisy

© 2022 - 2024 — McMap. All rights reserved.