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: README.md
+66-13Lines changed: 66 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -269,24 +269,77 @@ jobs:
269
269
force_with_lease: true
270
270
```
271
271
272
+
An example workflow to pull remote changes before pushing (useful when multiple jobs or actors push to the same branch concurrently):
273
+
274
+
> [!IMPORTANT]
275
+
> The `pull` input requires the repository to be checked out **on a real branch** (not in detached HEAD state).
276
+
> `git pull` does not work in detached HEAD state and the action will abort with an error if this is detected.
277
+
> Make sure to pass an explicit `ref` to `actions/checkout` so that a branch is checked out, e.g. `ref: ${{ github.head_ref }}` for pull-request workflows or `ref: main` for push workflows.
278
+
279
+
```yaml
280
+
jobs:
281
+
build:
282
+
runs-on: ubuntu-latest
283
+
steps:
284
+
- uses: actions/checkout@v4
285
+
with:
286
+
ref: ${{ github.ref_name }} # must be a branch, not a tag or SHA (detached HEAD)
| ssh | boolean | false | Determines if ssh/ Deploy Keys is used. |
278
-
| branch | string | (default) | Destination branch to push changes. <br /> Can be passed in using `${{ github.ref }}`. |
279
-
| force | boolean | false | Determines if force push is used. |
280
-
| force_with_lease | boolean | false | Determines if force-with-lease push is used. Please specify the corresponding branch inside `ref` section of the checkout action e.g. `ref: ${{ github.head_ref }}`. Be aware, if you want to update the branch and the corresponding tag please use the `force` parameter instead of the `force_with_lease` option. |
281
-
| atomic | boolean | true | Determines if atomic push is used. |
282
-
| push_to_submodules | string | 'on-demand' | Determines if --recurse-submodules=<strategy> is used. The value defines the used strategy. |
283
-
| push_only_tags | boolean | false | Determines if the action should only push the tags, default false |
284
-
| tags | boolean | false | Determines if `--tags` is used. |
285
-
| directory | string | '.' | Directory to change to before pushing. |
286
-
| repository | string | '' | Repository name. <br /> Default or empty repository name represents <br /> current github repository. <br /> If you want to push to other repository, <br /> you should make a [personal access token](https://github.com/settings/tokens) <br /> and use it as the `github_token` input. |
| ssh | boolean | false | Determines if ssh/ Deploy Keys is used. |
310
+
| branch | string | (default) | Destination branch to push changes. <br /> Can be passed in using `${{ github.ref }}`. |
311
+
| force | boolean | false | Determines if force push is used. |
312
+
| force_with_lease | boolean | false | Determines if force-with-lease push is used. Please specify the corresponding branch inside `ref` section of the checkout action e.g. `ref: ${{ github.head_ref }}`. Be aware, if you want to update the branch and the corresponding tag please use the `force` parameter instead of the `force_with_lease` option. |
313
+
| atomic | boolean | true | Determines if atomic push is used. |
314
+
| push_to_submodules | string | 'on-demand' | Determines if --recurse-submodules=<strategy> is used. The value defines the used strategy. |
315
+
| push_only_tags | boolean | false | Determines if the action should only push the tags, default false |
316
+
| tags | boolean | false | Determines if `--tags` is used. |
317
+
| directory | string | '.' | Directory to change to before pushing. |
318
+
| repository | string | '' | Repository name. <br /> Default or empty repository name represents <br /> current github repository. <br /> If you want to push to other repository, <br /> you should make a [personal access token](https://github.com/settings/tokens) <br /> and use it as the `github_token` input. |
319
+
| pull | string | false | Perform a `git pull` before pushing. Accepted values: `rebase`(or `true`) uses `--rebase`, `merge` uses `--no-rebase`, `ff-only` uses `--ff-only`. Leave unset or `false` to skip the pull entirely. **Requires a real branch to be checked out** (detached HEAD state is not supported — the action will abort with an error). |
287
320
288
321
## Troubleshooting
289
322
323
+
If you see the following error when the `pull` input is enabled:
324
+
325
+
```log
326
+
Error: 'pull' is enabled but the repository is in detached HEAD state.
327
+
git pull only works when a branch is currently checked out.
328
+
```
329
+
330
+
This means `actions/checkout` checked out a commit SHA or tag instead of a branch, leaving the repository in [detached HEAD state](https://git-scm.com/docs/git-checkout#_detached_head). `git pull` does not work in that state.
331
+
332
+
**Fix:** Pass an explicit branch `ref` to `actions/checkout`:
333
+
334
+
```yaml
335
+
- uses: actions/checkout@v4
336
+
with:
337
+
ref: ${{ github.head_ref }} # for pull_request workflows
338
+
# or
339
+
# ref: ${{ github.ref_name }} # for push workflows
340
+
fetch-depth: 0
341
+
```
342
+
290
343
If you see the following error inside the output of the job, and you want to update an existing Tag:
Copy file name to clipboardExpand all lines: action.yml
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,10 @@ inputs:
46
46
description: 'Directory to change to before pushing.'
47
47
required: false
48
48
default: '.'
49
+
pull:
50
+
description: 'Determines if a pull should be performed before pushing. Accepts rebase, merge, ff-only, or true. When set to true, uses rebase. Default false. Requires the repository to be checked out on a real branch (not in detached HEAD state); the action will abort with an error if a detached HEAD is detected.'
0 commit comments