如何获取GitHub操作中特定步骤的输出? [英] How do I get the output of a specific step in GitHub Actions?
本文介绍了如何获取GitHub操作中特定步骤的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个运行测试的GitHub操作工作流,但现在我在其中集成了松弛通知。我要获取Run tests
步骤的输出,并在松弛步骤中将其作为消息发送。
- 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 }}
推荐答案
您需要做3件事:
- 将
id
添加到要从中获得输出的步骤 - 使用
set-output
命令创建输出 - Use the id和另一个步骤中的输出名称,以获取输出,然后join将它们放入一条消息中以备空闲
- name: Run tests
run: |
echo "::set-output name=mix-compile--warnings-as-errors::$(mix compile --warnings-as-errors)
"
echo "::set-output name=mix-format--check-formatted::$(mix format --check-formatted)
"
echo "::set-output name=mix-ecto_create::$(mix ecto.create)
"
echo "::set-output name=mix-ecto_migrate::$(mix ecto.migrate)
"
echo "::set-output name=mix-test::$(mix test)
"
id: run_tests
env:
MIX_ENV: test
PGHOST: localhost
PGUSER: postgres
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_MESSAGE: ${{join(steps.run_tests.outputs.*, '
')}}
SLACK_TITLE: CI Test Suite
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
有关输出名称说明,请参阅Metadata Syntax
这篇关于如何获取GitHub操作中特定步骤的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文