mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-15 07:43:20 +08:00
Add run ID parameter to API trigger for enhanced build requests
This commit is contained in:
3
.cnb.yml
3
.cnb.yml
@@ -20,7 +20,8 @@ main:
|
||||
stages:
|
||||
- name: API触发上传
|
||||
script: |
|
||||
echo run id: $RUN_ID
|
||||
cd .github/workflows
|
||||
pip install -r requirements.txt
|
||||
python github_download_and_cnb_upload.py --cnb-token $CNB_TOKEN --github-token $GITHUB_TOKEN
|
||||
python github_download_and_cnb_upload.py --cnb-token $CNB_TOKEN --github-token $GITHUB_TOKEN --run-id $RUN_ID
|
||||
echo api done!
|
||||
16
.github/workflows/cnb_trigger.py
vendored
16
.github/workflows/cnb_trigger.py
vendored
@@ -10,7 +10,7 @@ import json
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
def trigger_build(token, branch="main", event="api_trigger_one"):
|
||||
def trigger_build(token, branch="main", event="api_trigger_one", runid=None):
|
||||
"""
|
||||
触发构建请求
|
||||
|
||||
@@ -18,6 +18,7 @@ def trigger_build(token, branch="main", event="api_trigger_one"):
|
||||
token (str): 授权token
|
||||
branch (str): 分支名称,默认为main
|
||||
event (str): 事件类型,默认为api_trigger_one
|
||||
runid (str): 运行ID,可选参数
|
||||
|
||||
Returns:
|
||||
dict: API响应结果
|
||||
@@ -37,11 +38,17 @@ def trigger_build(token, branch="main", event="api_trigger_one"):
|
||||
"event": event
|
||||
}
|
||||
|
||||
# 如果提供了runid,则添加到env中
|
||||
if runid:
|
||||
data["env"] = {
|
||||
"RUN_ID": runid
|
||||
}
|
||||
|
||||
try:
|
||||
print(f"正在发起构建请求...")
|
||||
print(f"URL: {url}")
|
||||
print(f"分支: {branch}")
|
||||
print(f"事件: {event}")
|
||||
|
||||
print(f"请求体: {json.dumps(data, indent=2, ensure_ascii=False)}")
|
||||
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
|
||||
@@ -70,6 +77,7 @@ def main():
|
||||
parser.add_argument("token", help="授权token")
|
||||
parser.add_argument("--branch", default="main", help="分支名称 (默认: main)")
|
||||
parser.add_argument("--event", default="api_trigger_one", help="事件类型 (默认: api_trigger_one)")
|
||||
parser.add_argument("--runid", help="运行ID (可选)")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -77,7 +85,7 @@ def main():
|
||||
print("错误: 必须提供token参数")
|
||||
sys.exit(1)
|
||||
|
||||
result = trigger_build(args.token, args.branch, args.event)
|
||||
result = trigger_build(args.token, args.branch, args.event, args.runid)
|
||||
|
||||
if result is None:
|
||||
sys.exit(1)
|
||||
|
||||
3
.github/workflows/publish.yml
vendored
3
.github/workflows/publish.yml
vendored
@@ -559,4 +559,5 @@ jobs:
|
||||
env:
|
||||
CNB_TOKEN: ${{ secrets.CNB_TOKEN }}
|
||||
run: |
|
||||
python .github/workflows/cnb_trigger.py "$CNB_TOKEN"
|
||||
python .github/workflows/cnb_trigger.py "$CNB_TOKEN" --runid ${{ github.run_id }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user