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

Publish a package based on a PR comment #180

Open
mmkal opened this issue Aug 19, 2024 · 2 comments
Open

Publish a package based on a PR comment #180

mmkal opened this issue Aug 19, 2024 · 2 comments

Comments

@mmkal
Copy link
Contributor

mmkal commented Aug 19, 2024

Hello, loving pkg.pr.new so far! Has saved so much time fiddling already.

As discussed a bit via DM with @Aslemammad, I'm making an issue for the for-now pretty vague want I have of being able to publish a package based on my PRs, on other people's repos, even without them having pkg.pr.new installed.

Let's say I have a PR on someone else's repo that doesn't use pkg.pr.new (yet). Example: colinhacks/zod#3646. It would be great to still be able to get an easy shareable npm install ... command so that people can kick the tires on my proposal in their downstream projects, even without any interaction from the maintainer.

Since the PR is using my fork under mmkal, rather than colinhacks, and I have the pkg.pr.new GitHub app installed, in theory it may be possible for me to have a kind of shadow repo with an action which:

  1. Is triggered by an @ comment on GitHub
  2. receives the pull request URL for the comment
  3. uses the octokit API to get pull request metadata
  4. uses a GitHub actions workflow (defined... somewhere) to clone the head ref on the pull-request-creator's fork (i.e. in the above example the owner is mmkal not colinhacks)
  5. runs a build command specified in the comment?
  6. runs npx pkg-pr-new publish
  7. replies to the comment with the URL

So in the above example, all I'd need to do to get an installable version of zod with my new feature would be to leave a comment along the lines of:

@pkg-pr-new publish
build: yarn install && yarn build

Several parts of this might be tricky or impossible, including triggering via an @ comment on someone else's repo, figuring out where exactly to define this GitHub Actions workflow so that it has the necessary permissions, and also the best way to share a build command (like npm run build, but would vary by project) via a comment.

There would also be lots of repos with complex setups that this wouldn't work for, but that's probably fine to start with.

Also would need to be careful that it's only possible for mmkal to trigger an action in mmkal's GitHub org to make sure nothing unsafe happens.

But it feels like most of this should be possible? What do you think?

@Aslemammad
Copy link
Member

I think it is possible!

But the cost of installing the app and enabling workflows in the fork is way less than implementing this and the layers of abstractions it'd create!

what do you think?

@mmkal
Copy link
Contributor Author

mmkal commented Aug 20, 2024

Definitely true, but usually this would be needed on repos that have unresponsive maintainers, or who don't want to use pkg.pr.new for some reason. Adding it to the target repo on top of whatever change is actually proposed requires persuading the owners to add two things now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants