我在运行 GitHub 操作时生成这种格式的工作流程日志
${{ github.workflow }}-${{ github.run_id }}-${{ github.run_number }}.log
我想获取我们在其余调用中看到的工作流程 ID
"workflow_runs": [
{
"id": 30433642,
"name": "Build",
}
]
在这里检查:https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
有没有办法我们可以在运行 gh 操作时获取工作流程 id?
是的,这是可能的。
您可以从工作流程Github Context获取run_id。
{
"token": "***",
"job": "github-context",
"ref": "refs/pull/16/merge",
"sha": "b4f1729888b5c99abdf8a7a250ecc6cff1e180be",
"repository": "GuillaumeFalourd/poc-github-actions",
"repository_owner": "GuillaumeFalourd",
"repositoryUrl": "git://github.com/GuillaumeFalourd/poc-github-actions.git",
"run_id": "974568708",
"run_number": "2",
"retention_days": "90",
"actor": "GuillaumeFalourd",
"workflow": "24 - Github Context",
"head_ref": "feature/readme",
"base_ref": "main",
"event_name": "pull_request",
"event": {...}
}
通过 docs 对此答案的更新如下: ${{ github.run_id }}