Backend Architecture - Programmatically generating files and pushing to user's GitHub

Hey guys, I figured this would be a good place to get some input on how to go about this... So right now, I have a NextJS/Typescript app set up with GitHub Auth. The user fills out a form that which then gives me a long command line string to generate some files (using yarn/npm) -- I have up to this point done now. What I'm wondering about is this next part though, I want to run this command somewhere (Separate Linux VM? Right there on Vercel?) to generate the files, and then I also want to upload them to a new private repository on their GitHub account. Not sure what the best way to do this is. For some context, this app is fully hosted on Vercel, but I'm not sure I'll be able to just npm/yarn install stuff and create/delete files on Vercel's server. I'm thinking... - Should I set up a completely separate Linux VM and somewhere securely pass the GitHub credentials necessary over there? And then from there do the whole file generation, push to github, and then file deletion? - If so, how can I securely get the GitHub information/secrets from my current backend over to that server - Or should I do this on all on the Vercel server somehow? - Or is there another more obvious way that I'm not realizing?
5 Replies
Luke
Luke5mo ago
A Cloud Function / Lambda Function is always a good candidate for something like this.
Isaac
IsaacOP5mo ago
@Luke What would be good for using npm packages to add files though? and then theres also the whole thing of passing the github credentials which i dont even know how to start
Luke
Luke5mo ago
@Isaac I'm not too sure what your idea exactly is, so it's hard to give solid info without the full background But if I were you, I'd have a nice little web app, have them authenticate with GitHub, and then you should be good (depending on the scopes your application uses) to perform actions on behalf of them using the plain old GitHub API
upio
upio5mo ago
If you want to securely pass the creds u should use encryption
Isaac
IsaacOP5mo ago
Yeah so those first steps are basically what I have now, a web app with GitHub authentication. What I'm stuck on though from an architectural standpoint is where/how I should be running npm commands to generate the files that I want to generate for them, as well as upload to their github account
Want results from more Discord servers?
Add your server