The GitHub linkback feature posts comments on PRs/issues/commits when they are mentioned in Discourse posts. However, it never checked whether the GitHub PR/issue/commit already contained a link back to the same Discourse topic (in its description or existing comments). This led to redundant linkback comments when a PR already referenced the topic. Before posting a linkback comment, we now fetch the PR/issue body and existing comments (or commit comments) from the GitHub API and check whether any of them already contain a URL pointing to the same Discourse topic. URL matching uses Discourse.route_for — the same mechanism used by the oneboxer, search, and TopicLink — to reliably recognize all topic URL formats (/t/slug/id, /t/id, /t/id/post_number, etc.). On any GitHub API error, the check fails open (still posts the linkback) to preserve the pre-existing behavior — and because if the GET fails, the subsequent POST will likely fail too.
Discourse Github
https://meta.discourse.org/t/discourse-github/99895/
This plugin combines functionality of deprecated github_badges and discourse-github-linkback plugins.
Installation
Follow the plugin installation guide.
Github Badges
Assign badges to your users based on GitHub contributions.
How to use:
-
Enable
github badges enabledin Settings -> Plugins. -
Generate an access token on Github. Be sure to give it only the
public_reposcope. Paste that token into thegithub linkback access tokensetting. -
Add URL of the GitHub repo to scan for contributions to the
github badges reposite setting.
Github Linkback
Create a link from a Github pull request or commit back to a Discourse post where it is mentioned.
How to use:
-
Enable
github linkback enabledin Settings -> Plugins. -
Generate an access token on Github. Be sure to give it only the
public_reposcope. Paste that token into thegithub linkback access tokensetting. -
Finally, add the projects you wish to post to in the
github linkback projectssite setting in the formats:username/repositoryfor specific repositoriesusername/*for all repositories of a certain user
Github Permalink
Replace Github non-permalinks with permalinks.
How to use:
- Enable
github permalinks enabledin Settings -> Plugins. - If you want to exclude certain files or directories from permalink overwrites, you can modify that in the
github permalinks excludesite setting in the following formats:filenamelinks to all files with matching filenameusername/*links to all repositories belonging to the user/organizationusername/repository/*links to any file in the repositoryusername/repository/directory/*links to any file in the directory within repositoryusername/repository/file.rba specific file