获取github操作中特定步骤的输出 [英] Get output of a specific step in github actions
本文介绍了获取github操作中特定步骤的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个运行测试的GitHub action文件,但是现在我在其中集成了松弛通知.我想获取 Run tests
步骤的输出,并在松弛步骤中将其作为消息发送
I have this file of GitHub action which runs tests, but now I am integrating slack notification in it. I want to get the output of the Run tests
step and send it as a message in the slack step
- name: Run tests
run: |
mix compile --warnings-as-errors
mix format --check-formatted
mix ecto.create
mix ecto.migrate
mix test
env:
MIX_ENV: test
PGHOST: localhost
PGUSER: postgres
- name: Slack Notification
uses: rtCamp/action-slack-notify@master
env:
SLACK_MESSAGE: Run tests output
SLACK_TITLE: CI Test Suite
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
任何帮助将不胜感激.谢谢
Any help will be much appreciated. Thanks
推荐答案
您需要做3件事:
- Add an
id
to the step you want the output from - Create the outputs using the
set-output
command - Use the id and the output name in another step to get the outputs and then join them into one message for slack
- name: Run tests
run: |
echo "::set-output name=mix-compile--warnings-as-errors::$(mix compile --warnings-as-errors)\n"
echo "::set-output name=mix-format--check-formatted::$(mix format --check-formatted)\n"
echo "::set-output name=mix-ecto_create::$(mix ecto.create)\n"
echo "::set-output name=mix-ecto_migrate::$(mix ecto.migrate)\n"
echo "::set-output name=mix-test::$(mix test)\n"
id: run_tests
env:
MIX_ENV: test
PGHOST: localhost
PGUSER: postgres
- name: Slack Notification
uses: rtCamp/action-slack-notify@master
env:
SLACK_MESSAGE: ${{join(steps.run_tests.outputs.*, '\n')}}
SLACK_TITLE: CI Test Suite
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
请参见元数据语法用于输出名称描述
See Metadata Syntax for outputs name description
这篇关于获取github操作中特定步骤的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文