Original: https://codingcat.dev/post/cloud-function-github-update
Authentication using Nodegit
nodegit Authentication has become the biggest prolem with this entire process! I have added a comment to Issue 1035 but I don't know if it will get much traction as it seems there have been several issues out there already.
Failed Attempts
All of these attempts of course work for cloning, because I do not think it really checks
- sshKeyNew
return NodeGit.Cred.sshKeyNew('username', publicKeyContents, privateKeyContents, '').then(function (
cred
) {
assert.ok(cred instanceof NodeGit.Cred);
});
-
userpassPlaintextNew
shreturn NodeGit.Cred.userpassPlaintextNew(GITHUB_TOKEN, "x-oauth-basic");
### Successful Attempt - **sshKeyFromAgent** ```
sh return nodegit.Cred.sshKeyFromAgent(userName);
Cloud Funcitons
So the above sshKeyFromAgent works great while I am on my local Dev box (MacOS 10.14) after running the command ssh-add. I am currently running Node v10.14.1.I thought that it would be easy enough to do the same on a cloud function, but this took some digging. I then found out that Node 6 base image is on Debian, I thought it was Alpine.Interestingly they changed this in Node 8 base image to running Ubuntu 18.04, so I will have to keep an eye on this if Upgrading.
As many great things in life, sometimes you dribble down a lane that is direct into a double team...so you must pivot to score. (Wow it must be late, basketball analogies are showing up!)
simple-git aka git-js
I ended up switching to simple-git as nodegit ssh issues had me 2 days behind on trying to get out lesson 8. It provides a very simple interface to effectively accomplish everything I needed. It also allows me to use a personal token to do Git updates to GitHub which I liked a lot better.
Resources, Links & Official Documentation
- GitHub Documentation: Pull requests, GitHub Actions CI/CD, and repository security
- OWASP Top 10 & Application Security Guides: Vulnerability mitigation, authentication hardening, and CVE defense
Related CodingCat.dev Tutorials & Podcast Episodes
- RxFire in Svelte 3 using Firebase Firestore and Authentication: Introduction to Svelte3, Firebase, and RxFire. RxFire provides a set of observable creation methods. You simply call a function with some parameters to receive ...
- RxFire in ReactJS using Firebase Firestore and Authentication: Introduction to Create React App, Firebase, and RxFire. RxFire provides a set of observable creation methods. You simply call a function with some parameters to...
- Use Firestore to Build Hugo Content: Use a frontend app (Angular), to update a Firestore Backend, trigger Firebase Function, while maintaining git commits, and buld/deploy your Hugo site.
Frequently Asked Questions (FAQ)
What are the main takeaways from Cloud Function GitHub Update?
Changing git libraries. Cloud Function GitHub Update explores practical patterns for GitHub, Security in modern software engineering. Throughout this post, Alex Patterson breaks down real-world implementation details for GitHub, Security so developers can apply these patterns directly in production.
How do you implement GitHub best practices in production?
When adopting GitHub and Security in a production stack, start by validating your configuration against the GitHub Documentation (Pull requests, GitHub Actions CI/CD, and repository security). Focus on incremental adoption, automated testing, and observability so your team can measure performance and developer velocity improvements at each stage.
Where can I watch the full Cloud Function GitHub Update walkthrough and find related code resources?
You can explore the complete write-up and code examples right here on CodingCat.dev, and subscribe to the CodingCat.dev YouTube channel for weekly video tutorials. For a deeper dive into GitHub, check out our related guide: RxFire in Svelte 3 using Firebase Firestore and Authentication.
Top comments (0)