英文:
In Github actions get Shell stdout and post it in a PR Comment
问题
我正在创建一个CI/CD流水线,尝试获取Shell脚本的输出并将其发布在PR评论中,以下是我目前的进展:
-
名称:运行sh命令
id:sh
运行:bash ./update/commands.sh | tee output.txt -
名称:获取覆盖率输出
id:get_coverage
运行:echo "::set-output name=coverage < output.txt)" -
使用:mshick/add-pr-comment@v1
参数:- 消息:
覆盖率发现 ${{steps.get_coverage.outputs.coverage}}
🌏
! - 仓库令牌:${{ secrets.GITHUB_TOKEN }}
- 仓库令牌用户登录:'github-actions[bot]' # 临时GitHub令牌的用户登录
- 允许重复:false # 默认值
- 消息:
英文:
Im making a CI/CD pipeline and I'm trying to get the shell script output and post it in a PR comment and below is what I have so far.
I can see the shell script output when the pipeline runs but I struggling to save the output and post it in a PR comment.
- name: run sh command
id: sh
run: bash ./update/commands.sh | tee output.txt
- name: Get coverage output
id: get_coverage
run: echo "::set-output name=coverage < output.txt)"
- uses: mshick/add-pr-comment@v1
with:
message: |
Coverage found ${{steps.get_coverage.outputs.coverage}}
🌏
!
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
allow-repeats: false # This is the default
答案1
得分: 1
我个人会依赖 GitHub 命令行工具,非常容易向 Pull Request 添加评论:
gh pr comment 1234 --body-file file.txt
在这种情况下,我会将覆盖率的输出重定向到一个文件,然后将该文件的路径传递给 gh pr comment
。
确保你在工作流程文件中声明:
permissions:
issues: write
以确保工作流能够向问题添加评论。
英文:
I'd personally rely on the github cli from which it's very easy to add a comment to a PR:
gh pr comment 1234 --body-file file.txt
In this case I would redirect the output of the coverage to a file and then pass the path to that file to gh pr comment
.
make sure you declare:
permissions:
issues: write
In the workflow file to ensure the workflow can add comments to the issue.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论