在每个 CI 解决方案中,都可以暂停管道并等待手动批准才能继续(Jenkins、CircleCI、GitlabCI)。
如何使用 Github Actions 做到这一点?
Mat*_*ell 14
似乎您现在可以使用环境来执行此操作:https://docs.github.com/en/actions/managing-workflow-runs/reviewing-deployments
只需创建一个环境,选择所需的审阅者,添加您自己或团队,然后单击“保存”。
然后将环境关联到 Github Actions YAML 文件中,如下所示
environment:
name: <Your Github Environment here>
Run Code Online (Sandbox Code Playgroud)
然后,要发布该步骤,您可以单击“查看部署”,然后选择要部署的环境。
小智 8
仍然没有专门的功能来完成这项非常简单且需要的任务。不过我有一个解决方法。
如果您不使用环境,只需定义一个环境,将其称为“manual_approval”或类似的名称,并分配所需的审批者(可以是组)。这样就可以了。
如果您已经在使用环境,只需为每个环境定义 2 个环境条目(例如“prod”和“prod-manual”)。然后以相同的方式配置它们,只需在手动批准者上添加所需的批准者即可。
您现在只需在管道中添加此环境,如下例所示:
name: manual approval demo
on:
push:
jobs:
tf_plan:
name: Terraform Plan
runs-on: terraform
environment: Prod
steps:
...
tf_apply:
name: Terraform Apply
runs-on: terraform
environment: Prod-manual
steps:
...
Run Code Online (Sandbox Code Playgroud)
您必须为每个现实环境定义 2 个环境,因为工作流程每个作业只能引用一个环境。
现在有一种方法可以做到这一点(不确定什么时候开始可用,但我刚刚看到它)。所以基本上只需在工作流程之前添加“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
Run Code Online (Sandbox Code Playgroud)
现在,当您导航到“操作”选项卡并选择添加此命令的工作流程时,您会在列表上方看到“运行工作流程”下拉列表。使用此控件手动运行您的工作流程。
据我所知,目前没有手动触发。您只能重新运行失败的工作流程。
但有很多有用的活动可以实现类似的目标。
例如:标签事件:有人在 PR 上贴上“已批准”标签。
或者Pull 请求审核评论事件:有人评论“部署到阶段”。在公关上。
| 归档时间: |
|
| 查看次数: |
3144 次 |
| 最近记录: |