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

标签 github-actions

我们有部署通知,这些通知会发送到公司聊天室。当用户在本地运行代码时,有一些信息可以识别“谁运行了代码”($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.

关于github-actions - 如何获取用户名,负责在 github 操作中触发工作流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68141551/

相关文章:

github - 使用Github Actions发出API获取请求并将数据保存到repo

maven - 在 Github Actions 中获取 Maven 项目版本

node.js - 尝试将 Vue 应用程序部署到 Azure 应用程序服务,导致错误 : Cannot find module '../package.json'

python - Github工作人员找不到python脚本

ruby - Github Actions 无法在 ubuntu-18.04.5 上安装 Libv8 gem

github - Github 的 "Environment"和 "Repository" secret 之间的区别?

github-actions - Github Actions 在多个目录中运行 terraform init

google-chrome-extension - Puppeteer 无法在 GitHub 操作中启动

shell - 存储库 'http://security.debian.org/debian-security buster/updates InRelease' 将其 'Suite' 值从 'stable' 更改为 'oldstable'

java - 如何设置 GitHub Docker CI 为所有子模块运行