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
Update docs section about using the Action in public forks.
Add warning about current issue when the forks lives under an organisation.
Mark section about running a workflow in the head repository as outdated, as I was not able to reproduce this in test projects.
See #211 (comment) for more details.
Copy file name to clipboardExpand all lines: README.md
+20-3Lines changed: 20 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -282,11 +282,14 @@ See [this announcement from GitHub](https://github.blog/2020-08-03-github-action
282
282
<details>
283
283
<summary>Expand to learn more</summary>
284
284
285
-
> **Note**
285
+
> **Note**
286
286
> This Action technically works with forks. However, please note that the combination of triggers and their options can cause issues. Please read [the documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows) on which triggers GitHub Actions support.\
287
287
> Ensure your contributors enable "Allow edits by maintainers" when opening a pull request. ([Learn more](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)) \
288
288
> \
289
-
> If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch.
289
+
> **If you use this Action in combination with a linter/fixer, it's easier if you run the Action on `push` on your `main`-branch.**
290
+
291
+
> **Warning**
292
+
> Due to limitations of GitHub, this Action currently can't push commits to a base repository, if the fork _lives_ under an organisation. See [github/community#6634](https://github.com/orgs/community/discussions/5634) and [this comment](https://github.com/stefanzweifel/git-auto-commit-action/issues/211#issuecomment-1428849944) for details.
290
293
291
294
By default, this Action will not run on Pull Requests which have been opened by forks. (This is a limitation by GitHub, not by us.)
292
295
However, there are a couple of ways to use this Actions in Workflows that should be triggered by forked repositories.
@@ -312,10 +315,19 @@ on:
312
315
jobs:
313
316
php-cs-fixer:
314
317
runs-on: ubuntu-latest
318
+
permissions:
319
+
contents: write
320
+
315
321
steps:
316
322
- uses: actions/checkout@v3
317
323
with:
324
+
# Checkout the fork/head-repository and push changes to the fork.
325
+
# If you skip this, the base repository will be checked out and changes
# Checkout the branch made in the fork. Will automatically push changes
330
+
# back to this branch.
319
331
ref: ${{ github.head_ref }}
320
332
321
333
- name: Run php-cs-fixer
@@ -326,6 +338,11 @@ jobs:
326
338
327
339
### Workflow should run in **forked** repository
328
340
341
+
> **Warning**
342
+
> **This part of the documentation is outdated.**
343
+
> We were not able to configure a GitHub Action workflow for forks, that the workflow would run in the fork / head repository.
344
+
> Please let us know in the [discussions](https://github.com/stefanzweifel/git-auto-commit-action/discussions)-area, if and how you achieved that.
345
+
329
346
If the workflow should run in the forked repository, follow these steps:
330
347
331
348
1. In addition to listening to the `pull_request` event in your Workflow triggers, you have to add an additional event: `pull_request_target`. You can learn more about this event in [the GitHub docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target).
@@ -380,7 +397,7 @@ For more information about running Actions on forks, see [this announcement from
380
397
381
398
If you would like to use this Action to create a commit using [`--amend`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend) and [`--no-edit`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---no-edit) you need to make some adjustments.
382
399
383
-
> **Warning**
400
+
> **Warning**
384
401
> You should understand the implications of rewriting history if you amend a commit that has already been published. [See rebasing](https://git-scm.com/docs/git-rebase#_recovering_from_upstream_rebase).
385
402
386
403
First, you need to extract the previous commit message by using `git log -1 --pretty=%s`.
0 commit comments