Skip to content

Add QR code to comment - #98

Merged
rossjrw merged 4 commits into
rossjrw:mainfrom
lredoban:qr-code
Dec 30, 2025
Merged

Add QR code to comment#98
rossjrw merged 4 commits into
rossjrw:mainfrom
lredoban:qr-code

Conversation

@lredoban

Copy link
Copy Markdown
Contributor
Screenshot 2025-01-10 at 13 34 15

@rossjrw rossjrw added the enhancement New feature or request label Jan 10, 2025
@rossjrw

rossjrw commented Jan 10, 2025

Copy link
Copy Markdown
Owner

Oh, this is a really good idea. I'm into this.

I changed how the comment looks in #97 which will add a bit more space for the image, but I'd still like to make it a bit smaller, plus maybe some sort of size optimisation based on how long the URL is (the example size you've given could probably be smaller for short URLs, maybe it's too small for really big URLs).

https://goqr.me/api/ seems to be the operating site for qrserver.com, and their ToS is nonexistent so I'm not comfortable including it in this project. But it could be worth finding an alternative or just generating it on the runner.

@lredoban

Copy link
Copy Markdown
Contributor Author

You're totally right for qrserver.com, I've made some changes to generate the QR code with https://github.com/unjs/uqr.
But as github.qkg1.topments don't handle base64 images I have to put it inside a code block.
I put all this inside a "details" tag so it doesn't take space.

Let me know if I need to make some changes

Screenshot 2025-01-13 at 15 31 30

@rossjrw

rossjrw commented Dec 28, 2025

Copy link
Copy Markdown
Owner

I was taking another look at this... I just don't like the code block presentation, it feels messy to me, even though it results in a functional QR code. I tried braille (https://kbravh.dev/encoding-qr-codes-in-braille) and box-drawing characters (https://brhfl.com/2017/11/qr-codes/) too and I couldn't get anything to look good in a github.qkg1.topment.

I found like 50 API services offering a similar thing to goqr.me, and they fall into two camps which are a) free and suspiciously lacking in ToS, b) expensive enough that they're transparently some grifter using a free local generator to make a quick buck. At the end of the day I don't think I trust a single one of them not to eventually replace the images they serve with something terrible that at that point would be out of my control, already hardcoded into thousands of pull requests.

That leaves me with two options:

  • Generate the image locally and attach it to the comment. You already investigated that, found it doesn't work, and I came to the same conclusion. There is no GitHub API for attaching images to comments (https://github.com/orgs/community/discussions/28219), so they'd need to be hosted somewhere else.
    • I considered having the images be pushed to somewhere centralised - perhaps a repo that I control that serves its images through GitHub Pages. But, then all instances of this action would need to be authed to push to that repo, and I don't think that's possible to do securely given that this action runs statelessly in all sorts of environments including self-hosted actions runners.
  • Make my own QR code API.
    • I'm not charging for this action so I'd need to find some way to do it for free.
    • Users of this action would have no reason to trust that service, much like how I don't trust any of the existing services.

Not sure what the right approach is. But the idea of QR codes in preview comments has been stuck in my head ever since you initially raised this.

@rossjrw

rossjrw commented Dec 28, 2025

Copy link
Copy Markdown
Owner

Make my own QR code API.

<img src="https://qr.rossjrw.com/?url=https://github.com/rossjrw/pr-preview-action/pull/98" width="100"> <img src="https://qr.rossjrw.com/?url=https://github.com/rossjrw/pr-preview-action/pull/98&color.dark=f0f&color.light=0ff" width="100">

That wasn't too difficult

@rossjrw rossjrw changed the title Add Qr code to comment Add QR code to comment Dec 29, 2025
@rossjrw

rossjrw commented Dec 30, 2025

Copy link
Copy Markdown
Owner

I think this format works quite well

PR Preview Action v1.0.0-test

🚀 View preview at
https://test-owner.github.io/test-repo/pr-preview/pr-12345/12345-67890/123-4567890/12-34567890/1234-567890

Built to branch gh-pages at 2025-01-01 12:00 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

PR Preview Action v1.0.0-test

🚀 View preview at
https://test-owner.github.io/test-repo/pr-preview/pr-1

Built to branch gh-pages at 2025-01-01 12:00 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Passable on mobile, better if the URL isn't just a bunch of numbers, also looks better on the app but not as good as desktop. But if you're on your phone you don't need the qr code anyway. I'm happy with this layout (but feel free to suggest an alternative @anyone reading this)

@rossjrw
rossjrw merged commit 8d0e59d into rossjrw:main Dec 30, 2025
5 of 6 checks passed
@rossjrw

rossjrw commented Dec 30, 2025

Copy link
Copy Markdown
Owner

Released in v1.8.0. Thanks for the contribution @lredoban!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants