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

Simulate installation key in event body #6

Open
gr2m opened this issue Nov 4, 2022 · 2 comments
Open

Simulate installation key in event body #6

gr2m opened this issue Nov 4, 2022 · 2 comments

Comments

@gr2m
Copy link

gr2m commented Nov 4, 2022

In order to fully simulate a webhook event request that was triggered by a GitHub App, the "installation" key needs to be present. As --repo or --org need to be passed, we could retrieve the installation object with one of these requests

However the CLI would need the the GitHub App ID and Private Key in order to authenticate for these endpoints, the latter is quite long. Maybe a path to a .pem file would work?

gh webhook forward --url http://localhost:3000 --events issues --repo my-org/my-repo --secret '<my-secret>' --app-id 123 --app-private-key-path ./private-key.pem
@gr2m
Copy link
Author

gr2m commented Nov 25, 2022

I think a much simpler approach might be to just pass the installation id as CLI argument

--installation 123

and the plugin would add the installation key to the event payload based on it

  "installation": {
    "id": 123
  }

GitHub also sets installation.node_id, but at least from my experience, that key is not needed. installation.id is all that's required in order to create the installation access key

@gr2m
Copy link
Author

gr2m commented Nov 25, 2022

Yet another approach might be to set some kind of special header so that the app code knows it's run in a dev environment and need to get the installation by itself. The app already has access to the repository and the GitHub App credentials, that's all that is needed. It could be built into the GitHub App SDKs such as https://github.com/octokit/app.js. But I think I would prefer the other two options mentioned above, so we don't need different behavior depending on environment

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

1 participant