GitHub PR 部署管線
API SOP取得 PR 詳細資訊、檢查 CI 狀態、建立部署、等待狀態回傳、發布留言。
6 個節點 · 6 條連接api sops
apigithubdeploycicdsop
視覺化
GET /repos/{owner}/{repo}/pulls/{pr}api
擷取 Pull Request 詳細資訊,包含 head SHA
↓sequential→ GET /repos/{owner}/{repo}/commits/{sha}/check-runs
GET /repos/{owner}/{repo}/commits/{sha}/check-runsapi
確認所有 CI 檢查均已通過後再進行部署
↓conditional→ 部署核准
↓fallback→ 產生部署摘要
部署核准human
資深工程師審查 CI 結果並核准部署
↓sequential→ POST /repos/{owner}/{repo}/deployments
POST /repos/{owner}/{repo}/deploymentsapi
為 PR 的 head SHA 建立新的部署
↓sequential→ 產生部署摘要
產生部署摘要agent
AI 在 PR 上產生部署摘要留言
↓sequential→ POST /repos/{owner}/{repo}/issues/{pr}/comments
POST /repos/{owner}/{repo}/issues/{pr}/commentsapi
將 AI 產生的摘要發布為 PR 留言
ex-sop-github-pr-deploy.osop.yaml
osop_version: "1.0"
id: "sop-github-pr-deploy"
name:"GitHub PR 部署管線"
description:"取得 PR 詳細資訊、檢查 CI 狀態、建立部署、等待狀態回傳、發布留言。"
tags: [api, github, deploy, cicd, sop]
nodes:
- id: "get_pr"
type: "api"
subtype: "rest"
name: "GET /repos/{owner}/{repo}/pulls/{pr}"
description: "擷取 Pull Request 詳細資訊,包含 head SHA"
runtime:
method: "GET"
url: "https://api.github.com"
endpoint: "/repos/Archie0125/osop/pulls/1"
headers:
Authorization: "Bearer ${secrets.GITHUB_TOKEN}"
Accept: "application/vnd.github.v3+json"
outputs:
- head_sha: "data.head.sha"
- pr_number: "data.number"
- id: "check_ci"
type: "api"
subtype: "rest"
name: "GET /repos/{owner}/{repo}/commits/{sha}/check-runs"
description: "確認所有 CI 檢查均已通過後再進行部署"
runtime:
method: "GET"
url: "https://api.github.com"
endpoint: "/repos/Archie0125/osop/commits/${get_pr.head_sha}/check-runs"
headers:
Authorization: "Bearer ${secrets.GITHUB_TOKEN}"
outputs:
- all_passed: "data.check_runs[*].conclusion == 'success'"
- id: "human_approval"
type: "human"
subtype: "review"
name: "部署核准"
description: "資深工程師審查 CI 結果並核准部署"
security:
approval_gate: true
risk_level: "high"
- id: "create_deployment"
type: "api"
subtype: "rest"
name: "POST /repos/{owner}/{repo}/deployments"
description: "為 PR 的 head SHA 建立新的部署"
runtime:
method: "POST"
url: "https://api.github.com"
endpoint: "/repos/Archie0125/osop/deployments"
headers:
Authorization: "Bearer ${secrets.GITHUB_TOKEN}"
body:
ref: "${get_pr.head_sha}"
environment: "production"
auto_merge: false
outputs:
- deployment_id: "data.id"
- id: "post_comment"
type: "agent"
subtype: "llm"
name: "產生部署摘要"
description: "AI 在 PR 上產生部署摘要留言"
runtime:
provider: "anthropic"
model: "claude-haiku-4-5"
system_prompt: "Write a concise GitHub PR comment summarizing the deployment status. Include deployment ID and environment."
- id: "comment_api"
type: "api"
subtype: "rest"
name: "POST /repos/{owner}/{repo}/issues/{pr}/comments"
description: "將 AI 產生的摘要發布為 PR 留言"
runtime:
method: "POST"
url: "https://api.github.com"
endpoint: "/repos/Archie0125/osop/issues/${get_pr.pr_number}/comments"
headers:
Authorization: "Bearer ${secrets.GITHUB_TOKEN}"
body:
body: "${post_comment.output}"
edges:
- from: "get_pr"
to: "check_ci"
mode: "sequential"
- from: "check_ci"
to: "human_approval"
mode: "conditional"
condition: "check_ci.all_passed == true"
- from: "human_approval"
to: "create_deployment"
mode: "sequential"
- from: "create_deployment"
to: "post_comment"
mode: "sequential"
- from: "post_comment"
to: "comment_api"
mode: "sequential"
- from: "check_ci"
to: "post_comment"
mode: "fallback"