我正在尝试熟悉Github Actions。我已经以某种方式配置了工作流程,每次将代码推送到GitHub时,代码都会自动生成并推送到heroku。
如何在不访问github.com的情况下在终端中访问构建日志信息?
答案 0 :(得分:2)
使用最新的 cli/cli
tool named gh
(1.9.0+),您只需执行
(从您的终端, 转到 github.com
):
gh run view <jobId> --log
# or
gh run view <jobId> --log-failed
见“Work with GitHub Actions in your terminal with GitHub CLI”
<块引用>使用新的 gh run list
,您可以概览所有类型的工作流运行,无论它们是通过推送、拉取请求、网络钩子还是手动事件触发的。
要深入了解单次运行的详细信息,您可以使用 gh run view
,可选择深入了解作业的各个步骤。
对于更神秘的失败,您可以将 grep 等工具与 gh run view --log
结合使用,以搜索运行的整个日志输出。
如果 --log
信息过多,gh run --log-failed
将仅输出失败的各个步骤的日志行。
这非常适合直接查看失败步骤的日志,而不必自己运行 grep
。
答案 1 :(得分:1)
使用
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/<github-user>/<repository>/actions/workflows/<workflow.yaml>/runs
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs
这将返回具有以下结构的JSON:
{
"total_count": 1,
"workflow_runs": [
{
"id": 30433642,
"node_id": "MDEyOldvcmtmbG93IFJ1bjI2OTI4OQ==",
"head_branch": "master",
"head_sha": "acb5820ced9479c074f688cc328bf03f341a511d",
"run_number": 562,
"event": "push",
"status": "queued",
"conclusion": null,
"workflow_id": 159038,
"url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642",
"html_url": "https://github.com/octo-org/octo-repo/actions/runs/30433642",
"pull_requests": [],
"created_at": "2020-01-22T19:33:08Z",
"updated_at": "2020-01-22T19:33:08Z",
"jobs_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/jobs",
"logs_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/logs",
"check_suite_url": "https://api.github.com/repos/octo-org/octo-repo/check-suites/414944374",
"artifacts_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/artifacts",
"cancel_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/cancel",
"rerun_url": "https://api.github.com/repos/octo-org/octo-repo/actions/runs/30433642/rerun",
"workflow_url": "https://api.github.com/repos/octo-org/octo-repo/actions/workflows/159038",
"head_commit": {...},
"repository": {...},
"head_repository": {...}
]
}
使用具有存储库管理员权限的PAT访问jobs_url
。