You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/actions/get-started/understand-github-actions.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,10 @@ For a complete list of events that can be used to trigger workflows, see [Events
71
71
72
72
A **job** is a set of **steps** in a workflow that is executed on the same **runner**. Each step is either a shell script that will be executed, or an **action** that will be run. Steps are executed in order and are dependent on each other. Since each step is executed on the same runner, you can share data from one step to another. For example, you can have a step that builds your application followed by a step that tests the application that was built.
73
73
74
+
{% ifversion actions-nga %}
75
+
Steps run in order by default, but you can also run selected steps concurrently when your workflow benefits from parallel execution, such as starting a long-running service while later steps continue. For more information, see [AUTOTITLE](/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsbackground).
76
+
{% endif %}
77
+
74
78
You can configure a job's dependencies with other jobs; by default, jobs have no dependencies and run in parallel. When a job takes a dependency on another job, it waits for the dependent job to complete before running.
75
79
76
80
You can also use a **matrix** to run the same job multiple times, each with a different combination of variables—like operating systems or language versions.
Copy file name to clipboardExpand all lines: content/actions/reference/workflows-and-actions/workflow-syntax.md
+137Lines changed: 137 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -903,6 +903,143 @@ The maximum number of minutes to run the step before killing the process. Maximu
903
903
904
904
Fractional values are not supported. `timeout-minutes` must be a positive integer.
905
905
906
+
{% ifversion actions-nga %}
907
+
908
+
## `jobs.<job_id>.steps[*].background`
909
+
910
+
Runs a step asynchronously so the job continues to the next step without waiting for it to finish. Use `background: true` for long-running processes, such as databases, servers, or monitoring tasks, that need to run alongside other steps. You synchronize with background steps later using [`wait`](#jobsjob_idstepswait) or [`wait-all`](#jobsjob_idstepswait-all) or stop them with [`cancel`](#jobsjob_idstepscancel).
911
+
912
+
You can use `background` on steps that use `run` or `uses`. To reference a background step from [`wait`](#jobsjob_idstepswait) or [`cancel`](#jobsjob_idstepscancel), give it an [`id`](#jobsjob_idstepsid). A maximum of 10 background steps can run concurrently in a single job; additional background steps are queued until a slot is free.
913
+
914
+
Outputs and environment changes from a background step are only available after you run a `wait` or `wait-all` step that includes it. If a background step fails, the job fails at the next `wait` or `wait-all` that includes it (unless [`continue-on-error`](#jobsjob_idstepscontinue-on-error) is set on that step). An implicit `wait-all` runs before any post-job cleanup.
915
+
916
+
Use `background` when you need fine-grained control: starting a long-running process (like a server or database) that stays up while later steps run, referencing a specific step with [`wait`](#jobsjob_idstepswait) or [`cancel`](#jobsjob_idstepscancel), or interleaving background work with other steps. If you instead have a self-contained group of steps that should all finish before the job continues, [`parallel`](#jobsjob_idstepsparallel) is a more convenient shorthand.
917
+
918
+
### Example: Running a step in the background
919
+
920
+
```yaml
921
+
steps:
922
+
- name: Start server
923
+
id: server
924
+
run: npm start
925
+
background: true
926
+
927
+
- name: Run tests against the server
928
+
run: npm test
929
+
930
+
- name: Wait for the server step to finish
931
+
wait: server
932
+
```
933
+
934
+
## `jobs.<job_id>.steps[*].wait`
935
+
936
+
Pauses the job until one or more background steps complete. A `wait` step performs no work itself, it only blocks until the referenced background steps finish. Provide a single step `id` as a string, or multiple step `id`s as an array.
937
+
938
+
After a `wait` step completes, the outputs of the referenced background steps become available to subsequent steps. If a referenced background step failed, the `wait` step fails too.
939
+
940
+
### Example: Waiting for specific background steps
941
+
942
+
```yaml
943
+
steps:
944
+
- name: Build frontend
945
+
id: build-frontend
946
+
run: npm run build:frontend
947
+
background: true
948
+
949
+
- name: Build backend
950
+
id: build-backend
951
+
run: npm run build:backend
952
+
background: true
953
+
954
+
- name: Run linter while builds run
955
+
run: npm run lint
956
+
957
+
- name: Wait for both builds to finish
958
+
wait: [build-frontend, build-backend]
959
+
960
+
- name: Run tests
961
+
run: npm test
962
+
```
963
+
964
+
## `jobs.<job_id>.steps[*].wait-all`
965
+
966
+
Pauses the job until all active background steps complete. This is useful when several background steps are running and you want them all to finish before continuing. Like `wait`, the `wait-all` step fails if any of the background steps it waits on failed, unless you set [`continue-on-error`](#jobsjob_idstepscontinue-on-error) to `true`.
967
+
968
+
The `wait-all` keyword takes no arguments.
969
+
970
+
### Example: Waiting for all background steps
971
+
972
+
```yaml
973
+
steps:
974
+
- name: Start database
975
+
id: db
976
+
run: docker run -d postgres:15
977
+
background: true
978
+
979
+
- name: Start cache
980
+
id: cache
981
+
run: docker run -d redis:7
982
+
background: true
983
+
984
+
- name: Run integration tests
985
+
run: npm run test:integration
986
+
987
+
- name: Wait for all services to stop
988
+
wait-all:
989
+
```
990
+
991
+
## `jobs.<job_id>.steps[*].cancel`
992
+
993
+
Gracefully terminates a running background step. The runner sends the step's process a termination signal (`SIGTERM`) so it can clean up, and forcibly stops it (`SIGKILL`) if it does not exit within a short grace period. The `cancel` keyword targets a single background step by its `id`.
994
+
995
+
### Example: Canceling a background step
996
+
997
+
```yaml
998
+
steps:
999
+
- name: Start long-running monitor
1000
+
id: monitor
1001
+
run: ./scripts/monitor.sh
1002
+
background: true
1003
+
1004
+
- name: Run the main task
1005
+
run: npm test
1006
+
1007
+
- name: Stop the monitor
1008
+
cancel: monitor
1009
+
```
1010
+
1011
+
## `jobs.<job_id>.steps[*].parallel`
1012
+
1013
+
Runs a group of steps concurrently, then waits for all of them to finish before continuing. The `parallel` keyword is shorthand: every step in the group runs as a background step, with an implicit `wait` at the end of the group. Use it when you have an independent group of steps that can run at the same time and you don't need to reference them individually.
1014
+
1015
+
Use `parallel` when you have a self-contained group of steps that should all finish before the job moves on, such as building several components at once. Use [`background`](#jobsjob_idstepsbackground) when you need finer control: starting a long-running process (like a server or database) that stays up while later steps run, referencing a specific step with [`wait`](#jobsjob_idstepswait) or [`cancel`](#jobsjob_idstepscancel), or interleaving background work with other steps. In short, `parallel` is more limited but more convenient for the "run this group at once" case, while `background` is the general-purpose primitive.
1016
+
1017
+
Each step in the group is subject to the same 10-step concurrency limit as other background steps.
1018
+
1019
+
### Example: Running steps in parallel
1020
+
1021
+
```yaml
1022
+
steps:
1023
+
- uses: {% data reusables.actions.action-checkout %}
1024
+
1025
+
- parallel:
1026
+
- name: Build frontend
1027
+
run: npm run build:frontend
1028
+
1029
+
- name: Build backend
1030
+
run: npm run build:backend
1031
+
1032
+
- name: Build docs
1033
+
run: npm run build:docs
1034
+
1035
+
- name: Run tests after all builds complete
1036
+
run: npm test
1037
+
```
1038
+
1039
+
The group above is equivalent to declaring each step with `background: true` followed by a `wait` step.
1040
+
1041
+
{% endif %}
1042
+
906
1043
## `jobs.<job_id>.timeout-minutes`
907
1044
908
1045
The maximum number of minutes to let a job run before {% data variables.product.prodname_dotcom %} automatically cancels it. Default: 360
Copy file name to clipboardExpand all lines: content/actions/tutorials/migrate-to-github-actions/manual-migrations/migrate-from-jenkins.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,7 +76,7 @@ Jenkins uses directives to manage _Declarative Pipelines_. These directives defi
76
76
77
77
### Parallel job processing
78
78
79
-
Jenkins can run the `stages` and `steps` in parallel, while {% data variables.product.prodname_actions %} currently only runs jobs in parallel.
79
+
{% ifversion actions-nga %}Jenkins can run the `stages` and `steps` in parallel. {% data variables.product.prodname_actions %} runs jobs in parallel and can also run steps concurrently within a job using step-level syntax. For more information, see [AUTOTITLE](/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsbackground).{% else %}Jenkins can run the `stages` and `steps` in parallel, while {% data variables.product.prodname_actions %} currently only runs jobs in parallel.{% endif %}
80
80
81
81
| Jenkins Parallel | {% data variables.product.prodname_actions %} |
0 commit comments