【问题标题】:is there a way to get workflow id while running gh action有没有办法在运行 gh action 时获取工作流 id
【发布时间】:2021-12-02 02:24:10
【问题描述】:

我在运行 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 action 时获取工作流 ID?

【问题讨论】:

标签: github continuous-integration github-actions


【解决方案1】:

是的,有可能。

您可以从工作流 Github Context 中获取 run_id

公关活动中的 Github 上下文示例:

{
  "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": {...}
} 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-25
    • 2022-12-05
    • 2014-05-30
    • 1970-01-01
    • 2016-09-17
    相关资源
    最近更新 更多