github-actions - 如何获取用户名,负责在 github 操作中触发工作流

我们有部署通知,这些通知会发送到公司聊天室。当用户在本地运行代码时,有一些信息可以识别“谁运行了代码”($USER、$HOSTNAME 等)。

当从 CI 触发相同的代码时,我想获得有关此工作流程“谁是原因”的信息。可以是用户点击`workflow_dispatch'的github账号名,也可以是git中commit的author,也可以是author或PR等。

Github Actions 中是否有此类信息可用于工作流程?

最佳答案

您可能对 Github Context 感兴趣概念。

在那里,您会看到在每个工作流程中,您都可以访问上下文变量,例如 github.actor 变量以访问启动的用户登录工作流运行。

TIP: You can print the workflow GitHub variables using the following step:

- name: Show GitHub context   
  env: 
    GITHUB_CONTEXT: ${{ toJson(github) }}   
  run: echo "$GITHUB_CONTEXT"
  shell: bash

Otherwise, here is a payload sample to know what are the available variables.

https://stackoverflow.com/questions/68141551/

相关文章:

python - 如何在 python 数据框中做季度?

Python - 如何将 ImmutableDict 复制到可变字典?

android - Room - 模式导出目录未提供给注释处理器,因此我们无法导入模式

arrays - 谷歌表 : How to find the length of array?

r - 将 100 个数据帧合并为一个数据帧的函数

flutter - 如何将 'Function' 类型的参数分配给 'void Function()

rust - 改变 HashMap> 中的向量元素

algorithm - K个桶中N个对象的所有可能组合

javascript - 我们可以在 formik YupValidationSchema 中添加自

php - 找不到 Heroku 类 'NumberFormatter'