Maison > Article > outils de développement > comment exécuter les étapes d'actions github en parallèle
GitHub Actions allows you to specify the parallelism of steps within a job using the parallelism
keyword. By setting the parallelism level, you can control the maximum number of steps that can run concurrently within a job.
To specify the parallelism, use the following syntax within your .github/workflows/<workflow-file>.yml
file:
<code class="yaml">jobs: <job_id>: steps: - name: Step 1 run: echo "Step 1" - name: Step 2 run: echo "Step 2" - name: Step 3 run: echo "Step 3" steps: - name: Parallel Steps run: | echo "Running steps in parallel" echo "Step 1" echo "Step 2" echo "Step 3" parallelism: 3</code>
In this example, the parallelism
value is set to 3
, indicating that a maximum of three steps can run concurrently within the Parallel Steps
step.
Yes, it is possible to configure the number of parallel jobs that can run within a workflow using the jobs.concurrency
property. By specifying a concurrency group, you can limit the number of jobs that can run simultaneously, preventing resource contention and optimizing workflow performance.
To configure the number of parallel jobs, add the following to your .github/workflows/<workflow-file>.yml
file:
<code class="yaml">jobs: <job_id>: concurrency: group: <concurrency-group-name> cancel-in-progress: true</code>
In this example, the concurrency
property specifies a concurrency group named <concurrency-group-name>
. The cancel-in-progress
property is set to true
, indicating that any in-progress jobs will be canceled if the concurrency limit is reached.
Optimizing the performance of GitHub Actions by running steps concurrently can greatly improve workflow execution times. Here are some best practices to follow:
parallelism
keyword: Specify the parallelism
level for steps that can run concurrently. Consider setting appropriate parallelism values to maximize resource utilization while avoiding bottlenecks.Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!