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

Auto-update demo screenshot in README #9

Open
DexterStorey opened this issue Nov 3, 2023 · 19 comments ยท May be fixed by #23
Open

Auto-update demo screenshot in README #9

DexterStorey opened this issue Nov 3, 2023 · 19 comments ยท May be fixed by #23
Labels
enhancement New feature or request

Comments

@DexterStorey
Copy link
Contributor

It would be really cool if changes to the cra package automatically:

image

๐Ÿ˜ฎโ€๐Ÿ’จ

@maige-app maige-app bot added the enhancement New feature or request label Nov 3, 2023
@DexterStorey DexterStorey changed the title OUT OF POCKET feature request auto deploy demo on changes to main Nov 3, 2023
@iamshanvy
Copy link
Contributor

Interesting problem, I will experiment on my own repos to try to achieve this result

@arihanv
Copy link
Contributor

arihanv commented Nov 4, 2023

How exactly is this supposed to work?

@iamshanvy
Copy link
Contributor

@arihanv

tldr

  • Setup push to deploy on demo repo (i assume it's there)
  • Use some hosting for the image for readme of this repo
  • Everytime changes pushed in this repo, in pipeline do following
    -- pull demo repo
    -- delete contents of demo repo
    -- copy all contents of template from this repo to the demo repo
    -- push changes to demo repo
    -- wait for changes to be deployed
    -- use some sort of screenshot as api tool (there are a bunch) to get screenshot
    -- deploy newly created screenshot to the hosting provider (so that url of the image remains same, but image changes)

@arihanv
Copy link
Contributor

arihanv commented Nov 6, 2023

@DexterStorey

To deploy changes to the cra package automatically:

  • Instead of having a separate repo for the cra-demo, you could have a folder for it in this repo (create-rubric-app) and set a custom build command in vercel.json to build & deploy from that folder
  • For the screenshot of the demo, this can be done through a combination of puppeteer and Vercel Blob. Essentially, you can make a Github action to run a program that uses puppeteer to get an image of the deployed demo once the vercel deployment has been successfully completed. Then, you can save the image in vercel blob without a random suffix. Doing this will allow you to use the same URL but change the image behind it.

I would be happy to help build this out, but I don't have access to Rubric's Vercel deployment/config

@DexterStorey
Copy link
Contributor Author

DexterStorey commented Nov 7, 2023

@iamshanvy and @arihanv Thanks for laying out a path to accomplish this. I agree with the proposed implementation - a puppeteer generated - static image url - triggered by action is elegant.

I think @tedspare deployed the template from this repo to create-rubric-app.vercel.app. Not sure how that works - but I don't think the DB is currently functional.

Either way - the hardest part of this seems to be the screenshot.

I can set up the Vercel config in the account if anyone manages to get something working with puppeteer. This would be really cool - but no pressure, it's very much a nice to have and not blocking the core product.

@tedspare
Copy link
Contributor

tedspare commented Nov 7, 2023

Yep I deployed the template directly to Vercel and it's blocked by the Prisma DB provider being SQLite.

If we could make the DB provider dynamic (no longer supported), it could be set in .env.local as DATABASE_PROVIDER=sqlite and in prod env as DATABASE_PROVIDER=postgres.

Another approach is SQLite in prod (fine for a demo imo). This requires a persistent filesystem unlike serverless.

I think we're close, open to ideas ๐Ÿ™Œ

@tedspare
Copy link
Contributor

tedspare commented Nov 7, 2023

@DexterStorey

To deploy changes to the cra package automatically:

  • Instead of having a separate repo for the cra-demo, you could have a folder for it in this repo (create-rubric-app) and set a custom build command in vercel.json to build & deploy from that folder
  • For the screenshot of the demo, this can be done through a combination of puppeteer and Vercel Blob. Essentially, you can make a Github action to run a program that uses puppeteer to get an image of the deployed demo once the vercel deployment has been successfully completed. Then, you can save the image in vercel blob without a random suffix. Doing this will allow you to use the same URL but change the image behind it.

I would be happy to help build this out, but I don't have access to Rubric's Vercel deployment/config

Super cool idea that could be useful or a whole range of uses! Eg. link preview images, blog previews.

@arihanv
Copy link
Contributor

arihanv commented Nov 7, 2023

Hey! In order to fix DB issues and to have easier deployments, I propose using Vercel KV. It's commonly used by vercel ai services to store JSON data which is exactly what we have. This will go hand in hand with the Vercel deployment and is easy to configure

@arihanv
Copy link
Contributor

arihanv commented Nov 7, 2023

@iamshanvy and @arihanv Thanks for laying out a path to accomplish this. I agree with the proposed implementation - a puppeteer generated - static image url - triggered by action is elegant.

I think @tedspare deployed the template from this repo to create-rubric-app.vercel.app. Not sure how that works - but I don't think the DB is currently functional.

Either way - the hardest part of this seems to be the screenshot.

I can set up the Vercel config in the account if anyone manages to get something working with puppeteer. This would be really cool - but no pressure, it's very much a nice to have and not blocking the core product.

Hey @DexterStorey! I wrote some puppeteer code to generate a screenshot and it works well. I think we can make it even easier and just save the screenshot to a path (it does that by default) within the Github repo, and then dynamically change the image reference in the readme to refer to the screenshot or we can go with my previously proposed implementation.

Let me know what you want me to do with the code.

@DexterStorey
Copy link
Contributor Author

Hey! In order to fix DB issues and to have easier deployments, I propose using Vercel KV. It's commonly used by vercel ai services to store JSON data which is exactly what we have. This will go hand in hand with the Vercel deployment and is easy to configure

Good point - I think vercel postgres would be even easier.

@DexterStorey
Copy link
Contributor Author

Yep I deployed the template directly to Vercel and it's blocked by the Prisma DB provider being SQLite.

If we could make the DB provider dynamic (no longer supported), it could be set in .env.local as DATABASE_PROVIDER=sqlite and in prod env as DATABASE_PROVIDER=postgres.

Another approach is SQLite in prod (fine for a demo imo). This requires a persistent filesystem unlike serverless.

I think we're close, open to ideas ๐Ÿ™Œ

this is the way. Env the db type.

@DexterStorey
Copy link
Contributor Author

Hey @DexterStorey! I wrote some puppeteer code to generate a screenshot and it works well. I think we can make it even easier and just save the screenshot to a path (it does that by default) within the Github repo, and then dynamically change the image reference in the readme to refer to the screenshot or we can go with my previously proposed implementation.

Let me know what you want me to do with the code.

In this case we would commit the image every time? I think the code would probably go in the root in like a utils folder and be called by a GitHub action workflow in .github/workflows?

@arihanv
Copy link
Contributor

arihanv commented Nov 7, 2023

Yeah, I think the image would go in like a "public" or "assets" folder in the repo. Also, instead of Prisma, we should be using Drizzle ORM. It's much more performant and is kind of industry standard now, but this is not that important to change right now.

@DexterStorey
Copy link
Contributor Author

DexterStorey commented Nov 7, 2023

hop on gather -> island.rubriclabs.com

@arihanv
Copy link
Contributor

arihanv commented Nov 7, 2023

Hey @DexterStorey! I wrote some puppeteer code to generate a screenshot and it works well. I think we can make it even easier and just save the screenshot to a path (it does that by default) within the Github repo, and then dynamically change the image reference in the readme to refer to the screenshot or we can go with my previously proposed implementation.
Let me know what you want me to do with the code.

In this case we would commit the image every time? I think the code would probably go in the root in like a utils folder and be called by a GitHub action workflow in .github/workflows?

Yeah, I believe it would need to be a github action. Here is a reference from the Supabase GitHub. They use this action to automatically create embeddings of their docs once a change to their docs is pushed. https://github.com/supabase/supabase/blob/master/.github/workflows/search.yml

@arihanv
Copy link
Contributor

arihanv commented Nov 7, 2023

Hey! In order to fix DB issues and to have easier deployments, I propose using Vercel KV. It's commonly used by vercel ai services to store JSON data which is exactly what we have. This will go hand in hand with the Vercel deployment and is easy to configure

Good point - I think vercel postgres would be even easier.

I agree. what do you think of using vercel postgres as the default db provider. I feel like the more we integrate with Vercel, the easier it is to deploy.

@arihanv
Copy link
Contributor

arihanv commented Nov 7, 2023

hop on gather -> island.rubriclabs.com

Will hop on in about two hours if y'all are still gonna be there.

@iamshanvy
Copy link
Contributor

I will leave this issue, it seems that @arihanv can take care of it ๐Ÿ’ช

I feel like the more we integrate with Vercel, the easier it is to deploy.

need to be careful with the cost though

Drizzle ORM
is kind of industry standard now

debatable

puppeteer

just in case later, check out this tool, puppeteer in pipeline might slowdown builds (guessing)?
Also sounds like a pain to maintain

sorry for being an old man ๐Ÿ˜‚

@tedspare tedspare changed the title auto deploy demo on changes to main Auto-update demo screenshot in README Nov 7, 2023
@tedspare
Copy link
Contributor

just in case later, check out this tool, puppeteer in pipeline might slowdown builds (guessing)? Also sounds like a pain to maintain

we built an API to do this!

hard part imo would be editing the README from within gh actions

@tedspare tedspare linked a pull request Nov 28, 2023 that will close this issue
2 tasks
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 a pull request may close this issue.

4 participants