Mot*_*ter 6 workflow github github-api github-actions
在推送事件中,是否可以获得 PR 标题,以便我可以使用相同的内容来创建版本和标签。
目前,我无法在推送事件中获得 PR 头衔。
任何人都可以帮忙吗?
我实际上需要一个类似的用例。作为简化工作流程的一部分,我们需要检查 PR 标题是否包含 Jira 票证。
我到达以下 github 操作扩展 https://github.com/8BitJonny/gh-get-current-pr
需要注意的几点:如果在您的用例中您需要获得 PR 标题并且您的推送事件是pull_request您可以使用的github.head_ref(请参见此处 - https://docs.github.com/en/actions/learn-github-actions/ contexts#github-context),因为您在上下文中拥有信息。
然而,就我而言,我的活动只是push所以我没有这些信息。
这就是gh-get-current-pr有用的地方。
将以下内容添加到您的 github actions yaml
steps:
- uses: actions/checkout@v1
- uses: 8BitJonny/gh-get-current-pr@1.4.0
id: PR
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Verbose setting SHA when using Pull_Request event trigger to fix #16
sha: ${{ github.event.pull_request.head.sha }}
# Only return if PR is still open
filterOutClosed: true
- run: echo "Your PR is ${prNumber} and its JSON is ${prJSON}"
if: success() && steps.PR.outputs.number
env:
prNumber: ${{ steps.PR.outputs.number }}
# JSON object with the full PR object
prJSON: ${{ steps.PR.outputs.pr }}
# Direct access to common PR properties
prUrl: ${{ steps.PR.outputs.pr_url }}
prTitle: ${{ steps.PR.outputs.pr_title }}
prBody: ${{ steps.PR.outputs.pr_body }}
prCreatedAt: ${{ steps.PR.outputs.pr_created_at }}
prMergedAt: ${{ steps.PR.outputs.pr_merged_at }}
prClosedAt: ${{ steps.PR.outputs.pr_closed_at }}
prLabel: ${{ steps.PR.outputs.pr_labels }}
Run Code Online (Sandbox Code Playgroud)
这基本上是一个关于如何从 PR 步骤输出配置环境变量的示例。
| 归档时间: |
|
| 查看次数: |
3777 次 |
| 最近记录: |