英文:
GitHub pause in the middle of workflow action
问题
我已创建了GitHub工作流程。它首先部署到暂存环境,然后在合并时部署到生产环境。我想要的是在暂存环境中暂停部署(以便我可以在暂存环境上进行快速的稳定性测试),然后我有一些手动触发部署到生产环境的方式。
以下是工作流程的YAML文件:
name: main
on:
push:
branches:
- main
jobs:
test:
uses: ./.github/workflows/build-test.yml
secrets: inherit
staging:
uses: ./.github/workflows/staging-deploy.yml
secrets: inherit
prod:
name: 'Deploy to Prod'
uses: ./.github/workflows/deploy.yml
needs: [test, staging]
with:
stage: prod
secrets: inherit
注意:上述内容是您提供的GitHub工作流程的YAML文件。
英文:
I have created GitHub workflow. It deployed first on staging and than on the production environment on merge. What I want is to pause the deployment at staging, (so that I can do a quick sanity test on staging) and than I have some manual trigger to deploy to production.
Below is the workflow yml file.
name: main
on:
push:
branches:
- main
jobs:
test:
uses: ./.github/workflows/build-test.yml
secrets: inherit
staging:
uses: ./.github/workflows/staging-deploy.yml
secrets: inherit
prod:
name: 'Deploy to Prod'
uses: ./.github/workflows/deploy.yml
needs: [test, staging]
with:
stage: prod
secrets: inherit
答案1
得分: 0
GitHub Actions允许您通过使用环境来审查部署。
然后,您需要在工作流程中添加一个作业,要求在执行部署到生产环境之前获得批准。
示例中使用名为Prod
的环境请求审查:
name: main
on:
push:
branches:
- main
jobs:
test:
uses: ./.github/workflows/build-test.yml
secrets: inherit
staging:
uses: ./.github/workflows/staging-deploy.yml
secrets: inherit
manual-approval:
environment: 'Prod'
runs-on: ubuntu-20.04
needs:
- test
- staging
steps:
- run: echo "Approved to Prod"
prod:
name: 'Deploy to Prod'
uses: ./.github/workflows/deploy.yml
needs:
- manual-approval
with:
stage: prod
secrets: inherit
英文:
Github Actions allows you to review deployments by using environments.
First, you will need to create an environment in the repository, and add Reviewers to it.
Then, you will need to add a job in your workflow asking for this approval before executing the deploy to production.
Example with an environment named Prod
asking for review:
name: main
on:
push:
branches:
- main
jobs:
test:
uses: ./.github/workflows/build-test.yml
secrets: inherit
staging:
uses: ./.github/workflows/staging-deploy.yml
secrets: inherit
manual-approval:
environment: 'Prod'
runs-on: ubuntu-20.04
needs:
- test
- staging
steps:
- run: echo "Approved to Prod"
prod:
name: 'Deploy to Prod'
uses: ./.github/workflows/deploy.yml
needs:
- manual-approval
with:
stage: prod
secrets: inherit
答案2
得分: 0
- name: 暂停
run: sleep 3
英文:
To sleep for 3 seconds you can use
- name: Pause
run: sleep 3
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论