GitHub工作流程操作中暂停。

huangapple go评论136阅读模式
英文:

GitHub pause in the middle of workflow action

问题

我已创建了GitHub工作流程。它首先部署到暂存环境,然后在合并时部署到生产环境。我想要的是在暂存环境中暂停部署(以便我可以在暂存环境上进行快速的稳定性测试),然后我有一些手动触发部署到生产环境的方式。

以下是工作流程的YAML文件:

  1. name: main
  2. on:
  3. push:
  4. branches:
  5. - main
  6. jobs:
  7. test:
  8. uses: ./.github/workflows/build-test.yml
  9. secrets: inherit
  10. staging:
  11. uses: ./.github/workflows/staging-deploy.yml
  12. secrets: inherit
  13. prod:
  14. name: 'Deploy to Prod'
  15. uses: ./.github/workflows/deploy.yml
  16. needs: [test, staging]
  17. with:
  18. stage: prod
  19. 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.

  1. name: main
  2. on:
  3. push:
  4. branches:
  5. - main
  6. jobs:
  7. test:
  8. uses: ./.github/workflows/build-test.yml
  9. secrets: inherit
  10. staging:
  11. uses: ./.github/workflows/staging-deploy.yml
  12. secrets: inherit
  13. prod:
  14. name: 'Deploy to Prod'
  15. uses: ./.github/workflows/deploy.yml
  16. needs: [test, staging]
  17. with:
  18. stage: prod
  19. secrets: inherit

答案1

得分: 0

GitHub Actions允许您通过使用环境来审查部署

首先,您需要在存储库中创建一个环境,并向其添加审阅者

然后,您需要在工作流程中添加一个作业,要求在执行部署到生产环境之前获得批准。

示例中使用名为Prod的环境请求审查:

  1. name: main
  2. on:
  3. push:
  4. branches:
  5. - main
  6. jobs:
  7. test:
  8. uses: ./.github/workflows/build-test.yml
  9. secrets: inherit
  10. staging:
  11. uses: ./.github/workflows/staging-deploy.yml
  12. secrets: inherit
  13. manual-approval:
  14. environment: 'Prod'
  15. runs-on: ubuntu-20.04
  16. needs:
  17. - test
  18. - staging
  19. steps:
  20. - run: echo "Approved to Prod"
  21. prod:
  22. name: 'Deploy to Prod'
  23. uses: ./.github/workflows/deploy.yml
  24. needs:
  25. - manual-approval
  26. with:
  27. stage: prod
  28. 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:

  1. name: main
  2. on:
  3. push:
  4. branches:
  5. - main
  6. jobs:
  7. test:
  8. uses: ./.github/workflows/build-test.yml
  9. secrets: inherit
  10. staging:
  11. uses: ./.github/workflows/staging-deploy.yml
  12. secrets: inherit
  13. manual-approval:
  14. environment: 'Prod'
  15. runs-on: ubuntu-20.04
  16. needs:
  17. - test
  18. - staging
  19. steps:
  20. - run: echo "Approved to Prod"
  21. prod:
  22. name: 'Deploy to Prod'
  23. uses: ./.github/workflows/deploy.yml
  24. needs:
  25. - manual-approval
  26. with:
  27. stage: prod
  28. secrets: inherit

答案2

得分: 0

  • name: 暂停
    run: sleep 3
英文:

To sleep for 3 seconds you can use

  1. - name: Pause
  2. run: sleep 3

huangapple
  • 本文由 发表于 2023年7月10日 20:09:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76653597.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定