【发布时间】:2021-10-30 20:52:14
【问题描述】:
在每个 CI 解决方案中,都可以暂停管道并等待手动批准才能继续(Jenkins、CircleCI、GitlabCI)。
如何使用 Github Actions 做到这一点?
【问题讨论】:
-
可能的解决方法:可能通过评论触发运行? github.community/t/…
标签: github-actions
在每个 CI 解决方案中,都可以暂停管道并等待手动批准才能继续(Jenkins、CircleCI、GitlabCI)。
如何使用 Github Actions 做到这一点?
【问题讨论】:
标签: github-actions
Afaik 目前没有手动触发。您只能重新运行失败的工作流。
但是有很多有用的事件可以实现类似的事情。
例如:Label event:有人在 PR 上贴上“已批准”标签。
或者Pull request review comment event:有人在“部署到舞台”。在公关上。
【讨论】:
看来你现在可以使用环境来做到这一点:https://devblogs.microsoft.com/devops/i-need-manual-approvers-for-github-actions-and-i-got-them-now/
只需创建一个环境,选择所需的审阅者,添加您自己或团队,然后点击保存。
然后像这样在你的 Github Actions YAML 文件中关联环境
environment:
name: <Your Github Environment here>
然后要发布该步骤,您可以单击“Review Deployments”,然后选择要部署的环境。
【讨论】:
现在有一种方法可以做到(不确定何时开始可用,但我刚刚看到了)。所以基本上只需在你的工作流程之前添加“workflow_dispatch:”
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
现在,当您导航到“操作”选项卡并选择您添加此命令的工作流程时,您会在列表上方看到“运行工作流程”下拉菜单。使用此控件手动运行您的工作流程。
【讨论】:
目前没有手动触发,但是,Github 提供了 on_dispatch 事件,您可以将其作为目标来启动重新运行。您可以通过 curl 或从 Postman 中执行此操作。我已经用 Postman 编写了一个解决方案,并在此处包含了屏幕截图: https://medium.com/@christinavhastenrath/how-to-run-github-actions-manually-afebbe77d325
Github 也刚刚发布了他们的 GitHub Actions API,可用于构建触发器。您可以在此处找到 API 文档:https://developer.github.com/v3/actions/
GitHub 官方的回应是,他们正在考虑无条件地重新运行某个操作,但尚未得到任何确认。您可以在此处关注 Github 社区中的任何更新:https://github.community/t5/How-to-use-Git-and-GitHub/Is-it-possible-to-manually-force-an-action-workflow-to-be-re-run/td-p/25336
【讨论】: