mirror of
https://github.com/healthchecks/healthchecks.git
synced 2026-04-25 15:05:49 +03:00
[GH-ISSUE #671] Github Issues #483
Labels
No labels
bug
bug
bug
feature
good-first-issue
new integration
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/healthchecks#483
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @andres-usheru on GitHub (Jun 23, 2022).
Original GitHub issue: https://github.com/healthchecks/healthchecks/issues/671
To create an issue in Github issues when an alert fires
@fukawi2 commented on GitHub (Jun 7, 2023):
This would be really useful for us too, so adding my +1
@JPaulMora commented on GitHub (Apr 17, 2024):
I can help develop this, anything I should consider @cuu508?
@JPaulMora commented on GitHub (Apr 17, 2024):
Okay I have started work on this, seems that the Github API does support what we're looking for, however I have some questions about implementation.
Currently a single integration can be used for many checks, for that we'd have to consider
@cuu508 commented on GitHub (Apr 18, 2024):
The way I'm imagining the integration would work is – when a check goes down, Healthchecks creates a new GitHub issue titled something like "<check-name> is DOWN" and more details in the issue body. For that I think we would need an access token with a read/write access to issues. Looks like that's possible: https://stackoverflow.com/a/78226880/5821
The integration could also comment on the issue when the check goes back up, but that's in the "nice to have" category.
@fukawi2 commented on GitHub (Apr 18, 2024):
That's basically what I was imagining. The "integration" would be configured to create the issue in a specific repository. Ideally with (optional) Labels added to the issue.
Commenting / closing it when the check goes back up would only be a "nice to have" feature IMO too.
@cuu508 commented on GitHub (Apr 18, 2024):
Alright, happy to review a PR.
There's a checklist for developing a new integration in CONTRIBUTING.md
@cuu508 commented on GitHub (Apr 18, 2024):
Regarding labels, GitHub API docs have this note:
I'm not sure but I assume API actions performed with a personal access token would show up as performed by the user who created the PAT. And there's a good chance this user does have push access.
What labels would we want to set? Isn't every repository different in how it's using the labels?
Regarding commenting on issues, or closing issues when a check goes up, I think this will be tricky. When we create a new issue, GitHub will report back the issue number. We don't have a way to store the issue number, so we can find the right issue to comment on, or close later.
A sort-of similar integration is Trello. This integration only creates Trello cards, it does not comment on them or archive them.
@JPaulMora commented on GitHub (Apr 18, 2024):
What I was thinking is, if we're gonna configure the repo and PAT at the notification level there would only be a single global repository we could notify issues to. eg I would not be able to monitor/alert multiple repos, right?
@cuu508 commented on GitHub (Apr 18, 2024):
@JPaulMora yes, but that's how the other integrations work as well: when you set up a Slack integration, you select a channel, and the integration later only posts to that channel. When you set up a Trello integration, you select a board and a list, and it only adds cards to that single list. When you set up a Telegram integration, you select a chat group, and the integration only posts to that one group.
Users can set up multiple integrations of the same type though, each with different settings. You could have two GitHub integrations in the same project, one creating issues in repo ABC, and the other creating issues in repo XYZ. Then you would assign one or the other integration to checks as needed.
@fukawi2 commented on GitHub (Apr 19, 2024):
Well at least if the PAT doesn't have the permissions, they would be silently dropped (rather than causing an error).
That would be configurable in the integration. In our specific case, we have various labels that are tied to webhooks that "do things". As an example, we have a label ("Infra") that when added to an issue, auto-assigns a random member of our Infra team.
So the workflow I'm envisaging with this integration is:
We have 1 and 3, just need 2 to join them together 😄
Yeah, it's definitely an optional extra, not a hard requirement IMO.
@cuu508 commented on GitHub (Feb 18, 2025):
I had a closer look at authentication options.
We previously discussed using personal access tokens. These would be the easiest from the implementation perspective – Healthchecks would provide instructions to the user how to generate a PAT, take the PAT from the user, then use it in the "Create Issue" API call. Drawbacks:
Looking at other options, GitHub has two types of apps that can be used to acquire access tokens, OAuth apps and GitHub apps.
The OAuth app option seems relatively straightforward: I register an OAuth app which gives client id and client secret. End user authenticates via OAuth, which in the end gives us an access token ("gho_***") which we can use with the "Create Issue" API call. Drawbacks:
Finally, there's GitHub apps. There's fine-grained permissions, and there's option to perform API actions as the app, not on behalf of the user. Yay! The only problem is I'm unsure how to properly and securely use them for the Healthchecks use case. The best I've come up so far is:
https://github.com/apps/{app-id}/installations/newhttps://github.com/login/oauth/access_tokento exchange code for an user access token ("ghu_***")https://api.github.com/user/installationsto retrieve the installations the user has access tohttps://api.github.com/app/installations/{installation-id}/access_tokensto acquire installation access token ("ghs_***") for the selected installationhttps://api.github.com/installation/repositoriesto retrieve the list of reposWhen it is time to send an alert:
https://api.github.com/app/installations/{installation-id}/access_tokensto acquire installation access tokenI'm not at all sure I got the flow right. Initially I thought the user access token is not needed at all, as soon as we get the installation_id back from the GitHub we can go create installation access token, and create issues using it! That's what ChatGPT cheerfully recommended too! Problem is, if Eve somehow finds out Alice's installation_id, it would be straightforward for Eve to set up GitHub integration pointing to one of Alice's repos. Basically the same issue as described here. In my mind, by acquiring the user access token and checking what installations the user has access to it, we prevent against it. But I'm not sure.
If anyone has experience with GitHub apps and GitHub authentication and can share advice, I would very much appreciate it!
@cuu508 commented on GitHub (Feb 19, 2025):
Revised flow:
https://github.com/login/oauth/authorize?client_id=...&state=....https://github.com/login/oauth/access_tokenhttps://api.github.com/user/installationsand using user's access token for authenticationhttps://api.github.com/user/installations/INSTALLATION_ID/repositoriesand using user's access token for authenticationWhen Healthchecks presents the list of available repos, it should also include a comment along the lines of "Don't see the repo you are looking for? [Click Here] to install Healthchecks in you GithHub personal or organization account". The link would take the user to the GitHub app's installation page.
@cuu508 commented on GitHub (Feb 26, 2025):
I have deployed the first, experimental version of GitHub integration to Healthchecks.io. Anyone interested is welcome to try it out, and I will appreciate all feedback.
@fukawi2 commented on GitHub (Feb 27, 2025):
Amazing! I just tested it, it's perfect for us, thank-you! 👍 ❤
@cuu508 commented on GitHub (Mar 5, 2025):
Blog post: https://blog.healthchecks.io/2025/03/new-integration-github-issues/