github-actions - 在 GitHub Action 中插入表达式

标签 github-actions

我正在使用 mshick/add-pr-comment GitHub 操作向 PR 发送消息。

我不需要发送静态文本(如示例中所示),而是需要一条动态消息,它是以下表达式的结果: cat rs/coverage/.last_run.json | cat rs/coverage/.last_run.json | jq '.result.line'

如何插入这样的表达式?

我已经尝试过,但它发送的是确切的字符串,而不是它的结果。

- uses: mshick/add-pr-comment@v1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
   with:
     message: $(cat reaction6/coverage/.last_run.json | jq '.result.line')

最佳答案

请尝试先设置变量,然后使用它:

- name: Create PR message
  run: echo "msg=$(cat reaction6/coverage/.last_run.json | jq '.result.line')" >> $GITHUB_ENV
- uses: mshick/add-pr-comment@v1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
   with:
     message: "${{ env.msg}}"

关于github-actions - 在 GitHub Action 中插入表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68019263/

相关文章:

github - 动态检索 GitHub 操作 key

github-actions - 仅当特定步骤失败时才运行 GitHub 操作步骤

github-actions - 我可以有多个 GitHub Actions 工作流程文件吗?

docker - 是否可以在 Azure DevOps Pipeline 中运行 GitHub Workflow Actions?

linux - 无法在 Linux 上安装 GitHub 操作运行器

rust - GitHub Actions 缓存 Rust 工件

postgresql - 如何连接到 GitHub Action 的作业服务?

git - 在 Github Actions 中克隆私有(private)仓库

github - 如何在 Github Action 中使用 yarn 安装私有(private)包?

github-actions - 如何在删除事件 Github 操作中提取分支名称