Run a New Github Actions Workflow Without Merging to the Main Branch

When developing a new Github Actions workflow there is no obvious way to test it before merging to main branch.

Use Github Cli to run a workflow from a non-main branch.

gh workflow run .github/workflows/deploy.yml  --ref=$(git rev-parse --abbrev-ref HEAD)

Since workflow_dispatch doesn’t work until there is at least one run, add a PR trigger and/or * trigger:

  pull_request: # Required for testing the workflow
  push: # Required for testing the workflow
    branches:
      - *

(Make sure to remove it later)

Second Head Post
This is a post from Second Head. So please, don’t expect too much.

Related Content