Skip to content

Instantly share code, notes, and snippets.

@garywill
Created January 30, 2025 06:21
Show Gist options
  • Save garywill/8cfcbda62197c145e100079fce334d3c to your computer and use it in GitHub Desktop.
Save garywill/8cfcbda62197c145e100079fce334d3c to your computer and use it in GitHub Desktop.
Manually trigget Github Action (CI) workflow by shell CLI (bash). 用shell手动触发一个Github Action上的workflow开始运行
#!/bin/bash
# https://docs.github.com/zh/rest/actions/workflows#create-a-workflow-dispatch-event
echo -n "Enter GitHub token: "
# Disable echo.
stty -echo
read token
# Enable echo.
stty echo
echo
username=
repo=
workflow_id=
ci_branch=
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $token" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$username/$repo/actions/workflows/$workflow_id/dispatches \
-d '{"ref":"'"$ci_branch"'"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment