Ale*_*der 7 github github-actions
有人可以用简单的英语解释一下 Github Actions 上作业级别和工作流程级别的并发性是如何工作的吗?我只是无法理解这个概念:(提前谢谢你。
正如其名称所暗示的那样,在工作级别 ( jobs.<job_id>.concurrency) 则相反:
\n\n您可以使用它
\njobs.<job_id>.concurrency来确保一次仅运行一个使用相同并发组的作业或工作流。
\n并发组可以是任何字符串或表达式。该表达式可以使用除“秘密”上下文之外的任何上下文。
您可以在 GitHub 工作流程上看到很多示例:
\n\n#########################################################\n# Concurrency allows to run 1 cycle at a time\n# If worflow is running, 2nd one will automatically go in pending state\n# if concurrency is enabled\n# If 1st running, 2nd in pending and 3rd is triggered then 2nd which was \n# in pending will be cancelled and only 3rd (latest) will run\n#\n# If this is enabled it will cancel current running and start latest\n# cancel-in-progress: true\n#\n# When a concurrent job or workflow is queued, \n# if another job or workflow using the same concurrency group in the repository \n# is in progress, the queued job or workflow will be pending. \n#\n# Any previously pending job or workflow in the concurrency group will be canceled. \n# To also cancel any currently running job or workflow in the same concurrency group, \n# specify cancel-in-progress: true.\n############################################################\n\nname: Concurrency Test\non:\n #Triggers the workflow on push or pull request events but only for the master branch\n # push:\n # branches: [ master ]\n # pull_request:\n # branches: [ master ]\n\n # Allows you to run this workflow manually from the Actions tab\n workflow_dispatch:\n\n\n# Concurrency can be used at workflow level or job leve\nconcurrency:\n group: build-and-test\n \n # If this is enabled it will cancel current running and start latest\n cancel-in-progress: true\n\n\njobs:\n build-and-test-on-pr:\n runs-on: ubuntu-latest\n\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n \n# Adding sleep time to keep one running and trigger 2nd to check concurrency\n - name: Build and code sim\n run: |\n echo "Starting the code build"\n sleep 3m\n echo "Finish the code build"\nRun Code Online (Sandbox Code Playgroud)\n在工作流程级别,以下是Constantine Kim \xea\xb9\x80\xed\x98\x84\xec\xa7\x84的示例:
\n\nconcurrency:\n group: ${{ github.repository }}-concurrency-for-workflow\n cancel-in-progress: false\n\non:\n push:\n branches:\n - playground/concurrency-for-job\n\njobs:\n concurrency-3:\n concurrency:\n group: ${{ github.repository }}-concurrency-for-job\n cancel-in-progress: false\n runs-on: ubuntu-latest\n steps:\n - run: |\n sleep 100\n echo "concurrency-for-job-test ${{github.job}}"\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
8064 次 |
| 最近记录: |