Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid reference, error 128 #278

Open
lukepighetti opened this issue Jan 5, 2023 · 6 comments
Open

Invalid reference, error 128 #278

lukepighetti opened this issue Jan 5, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@lukepighetti
Copy link

lukepighetti commented Jan 5, 2023

git-auto-commit Version

v4

Machine Type

Ubuntu (eg. ubuntu-latest)

Bug description

A contributor has a fork branch called contributor:card and is trying to merge it in to lukepighetti:main

It appears that git-auto-commit is trying to commit to lukepighetti:card instead of contributor:card

jobs:
  generate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: arduino/setup-task@v1
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
      - uses: subosito/flutter-action@v2
        with:
          channel: stable
      - run: task gen
      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Update generated files
          file_pattern: "*.g.dart"

When new generated files are found and this action is triggered to commit the new files, I get the following error

Started: bash /home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/entrypoint.sh
[20](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:21)
INPUT_REPOSITORY value: .
[21](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:22)
INPUT_STATUS_OPTIONS: 
[22](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:23)
INPUT_FILE_PATTERN: *.g.dart
[23](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:24)
INPUT_BRANCH value: card
[24](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:25)
From https://github.com/lukepighetti/mastodon_dart
[25](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:26)
 * [new branch]      lukepighetti/actions-task-2 -> origin/lukepighetti/actions-task-2
[26](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:27)
 * [new branch]      lukepighetti/cleanup-nov-15 -> origin/lukepighetti/cleanup-nov-15
[27](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:28)
 * [new branch]      lukepighetti/null-safety -> origin/lukepighetti/null-safety
[28](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:29)
 * [new branch]      main       -> origin/main
[29](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:30)
fatal: invalid reference: card
[30](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:31)
Error: Invalid status code: 128
[31](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:32)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/index.js:17:19)
[32](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:33)
    at ChildProcess.emit (node:events:390:28)
[33](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:34)
    at maybeClose (node:internal/child_process:1064:16)
[34](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:35)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
[35](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:36)
  code: 128
[36](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:37)
}
[37](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:38)
Error: Invalid status code: 128
[38](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:39)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/index.js:17:19)
[39](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:40)
    at ChildProcess.emit (node:events:390:28)
[40](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:41)
    at maybeClose (node:internal/child_process:1064:16)
[41](https://github.com/lukepighetti/mastodon_dart/actions/runs/3846888265/jobs/6552794001#step:6:42)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
@lukepighetti lukepighetti added the bug Something isn't working label Jan 5, 2023
@stefanzweifel
Copy link
Owner

stefanzweifel commented Jan 5, 2023

I assume it's this workflow file, right?
https://github.com/lukepighetti/mastodon_dart/blob/82b76b990435f9b3d8b69ec1778c686adedbc105/.github/workflows/main.yml#L4

You probably need to switch to listen to the pull_request_target event. Pushing commits in forks is a bit of a hassle. We added a section to the README a while ago about this: https://github.com/stefanzweifel/git-auto-commit-action#advanced-uses

I'm not 100% sure, if you can keep triggers for both pull_request_target and pull_request in your workflow.
(I have an open task to check if this behaviour still works with forks; just haven't had the time yet to test it.)


We should probably also update the example in the README, to make it clearer how the example works with forks.

@deitch
Copy link

deitch commented Jul 28, 2023

Ah, just came across this. Good thing I looked in issues first.

So the net of it is that it kind of is doable, but is hard to config, and might not work at all depending on the setup of the fork? And all due to GitHub limitations?

@stefanzweifel
Copy link
Owner

@deitch Yeah, this sums it up pretty nicely.
Technically kinda doable but you run into road blocks constantly, due to how GitHub wants GitHub Actions to work for forks.

@deitch
Copy link

deitch commented Jul 30, 2023

That really is a pity. I can see some real patterns where you might want generated stuff as part of your repo (i.e. committed in), but not have the user do it. This is like compilation, but unlike normal compiled binaries (where it doesn't make sense), here it does. My current use case is language bindings generated from protobufs, but I can see transpiled code, graph images, lots of other cases.

@stefanzweifel
Copy link
Owner

@deitch That's exactly the use case why I've created this project; and it does work as you described.

Problems sometimes appear when people use this Action in workflows that should work for both Maintainers and Forks in the exact same way.

In the past we had many discussions/issues around forks. Almost all issues have been resolved by changing the workflow or repository settings. I'm liking a few here; maybe they help you or others coming across this thread.

I also know of a couple of bigger GitHub organisations that use this action to fix code style issues in their open source projects.

For example @spatie is using the Action in a workflow that just listens to the push event. In a pull request from May the action successfully pushed a commit to the fork (commit sha 4e853b5)

Or the @laravel org uses this workflow in all repositories to fix code style uses. In their repositories they also just listen to the push event (link).

Both orgs receive a lot of community contributions for forks. So this Action seems to work for them. 🤔


But I have to be honest: I haven't invested much time into this project in the last few weeks or even months.
I just saw that the project is already being used by 60,000 repositories; my time investment doesn't give the usage justice.

In the next few weeks or months I would like to comb all issues and discussions and extract all relevant information and put that into the documentation and close/lock discussions with a link to the right place in the documentation.

@deitch
Copy link

deitch commented Aug 1, 2023

I just saw that the project is already being used by 60,000 repositories; my time investment doesn't give the usage justice.

I have that with some OSS stuff over the years. It is hard to find time to maintain them, unless you can build something commercial on top of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants