There are several ways to manually run a workflow on a GitHub repository:
## Method 1: Using GitHub Web Interface
1. **Navigate to your repository** on GitHub
2. **Go to the "Actions" tab**
3. **Select the workflow** you want to run from the left sidebar
4. **Click "Run workflow"** button (appears as a blue button on the right side)
5. **Select the branch** you want to run it on
6. **Fill in any required inputs** (if the workflow has them)
7. **Click "Run workflow"** to execute
## Method 2: Configure Workflow for Manual Trigger
Your workflow file (`.github/workflows/your-workflow.yml`) needs to include `workflow_dispatch` trigger:
```yaml
name: Your Workflow Name
on:
workflow_dispatch: # Enables manual trigger
inputs: # Optional: define manual inputs
environment:
description: 'Environment to deploy to'
required: true
default: 'staging'
type: choice
options:
- staging
- production
version:
description: 'Version to deploy'
required: false
default: 'latest'
jobs:
your-job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use input
run: echo "Deploying ${{ github.event.inputs.version }} to ${{ github.event.inputs.environment }}"
```
## Method 3: Using GitHub CLI
```bash
# Install GitHub CLI first if you haven't
# https://cli.github.com/
# Run a workflow manually
gh workflow run "workflow-name.yml"
# Or run by workflow ID
gh workflow run 12345
# Run on specific branch
gh workflow run "workflow-name.yml" --ref main
# Pass inputs to the workflow
gh workflow run "workflow-name.yml" -f environment=production -f version=v1.2.3
```
## Method 4: Using GitHub REST API
```bash
curl -X POST \
-H "Authorization: token YOUR_GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches \
-d '{"ref":"main","inputs":{"environment":"production"}}'
```
## Notes:
- The workflow must include `workflow_dispatch` in the `on:` section to be manually triggerable
- You need appropriate permissions (write access to the repository)
- Manual runs appear in the Actions tab with a "manually triggered" label
- You can also trigger workflows via `repository_dispatch` events for more complex scenarios
The most common and user-friendly method is using the GitHub web interface after adding `workflow_dispatch` to your workflow file.