File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
143
143
- [Checkout pull request HEAD commit instead of merge commit](#Checkout-pull-request-HEAD-commit-instead-of-merge-commit)
144
144
- [Checkout pull request on closed event](#Checkout-pull-request-on-closed-event)
145
145
- [Push a commit using the built-in token](#Push-a-commit-using-the-built-in-token)
146
+ - [Push a commit to a PR using the built-in token](#Push-a-commit-to-a-PR-using-the-built-in-token)
146
147
147
148
# # Fetch only the root files
148
149
@@ -288,6 +289,31 @@ jobs:
288
289
` ` `
289
290
*NOTE:* The user email is `{user.id}+{user.login}@users.noreply.github.com`. See users API: https://api.github.com/users/github-actions%5Bbot%5D
290
291
292
+ # # Push a commit to a PR using the built-in token
293
+
294
+ In a pull request trigger, `ref` is required as GitHub Actions checks out in detached HEAD mode, meaning it doesn’t check out your branch by default.
295
+
296
+ ` ` ` yaml
297
+ on: pull_request
298
+ jobs:
299
+ build:
300
+ runs-on: ubuntu-latest
301
+ steps:
302
+ - uses: actions/checkout@v4
303
+ with:
304
+ ref: ${{ github.head_ref }}
305
+ - run: |
306
+ date > generated.txt
307
+ # Note: the following account information will not work on GHES
308
+ git config user.name "github-actions[bot]"
309
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
310
+ git add .
311
+ git commit -m "generated"
312
+ git push
313
+ ` ` `
314
+ *NOTE:* The user email is `{user.id}+{user.login}@users.noreply.github.com`. See users API: https://api.github.com/users/github-actions%5Bbot%5D
315
+
316
+
291
317
# License
292
318
293
319
The scripts and documentation in this project are released under the [MIT License](LICENSE)
You can’t perform that action at this time.
0 commit comments