Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorThe web walker <contact@motss.app>2024-11-08 23:32:54 +0800
committerGitHub <noreply@github.com>2024-11-08 10:32:54 -0500
commitc982b802318a9bd8714755278dd27d190741ee8b (patch)
treea9419a438089c210cf100e7c07e721e5c57e5599 /README.md
parentb966f2e8554a60a31613ae5dceb034a6ed015fd2 (diff)
docs: update README.md (#1971)
Add a scenario where it is necessary to push a commit to a pull request.
Diffstat (limited to 'README.md')
-rw-r--r--README.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/README.md b/README.md
index e1ea032..a43e887 100644
--- a/README.md
+++ b/README.md
@@ -143,6 +143,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
- [Checkout pull request HEAD commit instead of merge commit](#Checkout-pull-request-HEAD-commit-instead-of-merge-commit)
- [Checkout pull request on closed event](#Checkout-pull-request-on-closed-event)
- [Push a commit using the built-in token](#Push-a-commit-using-the-built-in-token)
+- [Push a commit to a PR using the built-in token](#Push-a-commit-to-a-PR-using-the-built-in-token)
## Fetch only the root files
@@ -288,6 +289,31 @@ jobs:
```
*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
+## Push a commit to a PR using the built-in token
+
+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.
+
+```yaml
+on: pull_request
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ ref: ${{ github.head_ref }}
+ - run: |
+ date > generated.txt
+ # Note: the following account information will not work on GHES
+ git config user.name "github-actions[bot]"
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+ git add .
+ git commit -m "generated"
+ git push
+```
+*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
+
+
# License
The scripts and documentation in this project are released under the [MIT License](LICENSE)