Search code examples
githubgithub-actionsworkflowcicd

GitHub workflow workflow_dispatch missing in actions tab


I created a workflow file and the workflow is not showing up in the GitHub actions tab

name: AZ Deploy Workflow
on:
  workflow_dispatch:  
    inputs:
      deploy-environment:
        description: 'Environment to deploy to'
        required: true
        default: 'dev'
      image-tag:
        description: 'Docker tag to deploy'
        required: true
        default: 'latest'

any ideas what's the issue.

Earlier I have added other workflow into the .github directory that shows in actions with no issue even if a put a empty file it does but not this one


Solution

  • Make sure your workflow is located in the default branch.

    To run a workflow manually, the workflow must be configured to run on the workflow_dispatch event. To trigger the workflow_dispatch event, your workflow must be in the default branch. For more information about configuring the workflow_dispatch event, see "Events that trigger workflows".

    For more details, see the Manually running a workflow and about the default branch.

    UPD:

    Testing it from a branch other than from the main branch can be done using the GitHub REST API:

    curl \
      -X POST \
      -H "Accept: application/vnd.github+json" \
      -H "Authorization: Bearer <YOUR-TOKEN>"\
      -H "X-GitHub-Api-Version: 2022-11-28" \
      https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches \
      -d '{"ref":"test-branch","inputs":{"deploy-environment":"dev","image-tag":"latest"}}'
    

    You can replace WORKFLOW_ID with the workflow file name. For example, you could use main.yaml.

    ref - your branch name.

    For more details visit the official docs: Create a workflow dispatch event.