File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 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/
143143- [Checkout pull request HEAD commit instead of merge commit](#Checkout-pull-request-HEAD-commit-instead-of-merge-commit)
144144- [Checkout pull request on closed event](#Checkout-pull-request-on-closed-event)
145145- [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)
146147
147148# # Fetch only the root files
148149
@@ -288,6 +289,31 @@ jobs:
288289` ` `
289290*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
290291
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+
291317# License
292318
293319The 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