AutoDeploy your projects using Github WebHooks

I am a full stack developer. Currently doing some project on nextjs / nodejs
Working as SDE 3 in Netomi Hereβs my Resume: https://resume.devaman.dev
Search for a command to run...

I am a full stack developer. Currently doing some project on nextjs / nodejs
Working as SDE 3 in Netomi Hereβs my Resume: https://resume.devaman.dev
Is there any GitHub repo available or you could elaborate the process ?
i have added the screenshot of github. I am currently using this for my project also. Working perfect on my $5 droplet π. Just give it a try first if u have any error or doubt u can ask me here .
Recently i worked on Vue 3 migration. Migrating a Vue 2 application to Vue 3 is not just a dependency upgrade. The real work is in updating the application bootstrap, router, store, plugins, component

19/May/2023 While using mini-css-extract-plugin with vuejs and webpack 5, I was getting problem related to CSS priority. Scoped Css/Scss was not getting higher priority than common css. To resolve this issue we had to use oneof rule. In resourceQuery...

Hello everyone! I recently had the opportunity to work with AWS IoT to fetch real-time data. During the migration from Webpack 4 to Webpack 5, we encountered some issues with the aws-iot-device-sdk. While building our project, we encountered errors r...

Hey everyone , Webpack has released some new cool feature called module federation. Module Federation allows a JavaScript application to dynamically load code from another applicationβand βin the process, share dependencies. If an application consumi...

In this post I will tell you about on how to submit a pull request to the organization on which you are thinking to contribute. Now lets gets started with the steps... 1) Step 1 : Fork the repo. 2) Step 2 : Clone the repository.Open the terminal and ...

Amit Chambial Blog.
14 posts
Full Stack Developer and a maker. See my portfolio at https://portfolio.devaman.dev
Hey Everyone,
Many of us has this problem of deploying our github repo to EC2 machines or Digital Ocean's droplets or etc. We can automate this process by running a simple webhook script on our machine.
Lets start !
const secret = "secret-from-github";
const repo = "path-to-repo-on-machine(eg ~/react-project)";
const http = require('http');
const crypto = require('crypto');
const exec = require('child_process').exec;
const child = require('child_process');
http.createServer(function (req, res) {
let data= []
req.on('data', function(chunk) {
data.push(chunk);
});
req.on('end', () => {
let sig = "sha1=" + crypto.createHmac('sha1', secret).update(data.toString()).digest('hex');
if (req.headers['x-hub-signature'] == sig) {
if(JSON.parse(data).ref==='refs/heads/master'){
console.log('Deploying commit - ',JSON.parse(data).head_commit.message)
exec('cd ' + repo + ' && git pull origin master && npm install && npm run build && pm2 start npm -- start');
}
}
})
res.end();
}).listen(8080);
if(JSON.parse(data).ref==='refs/heads/master')ππ» git pull origin master
ππ» npm install
ππ» npm run build
ππ» pm2 start [pm2 is process manager for nodejs. you can replace it with npm start also ]
Note: git pull will ask for username and password.The prompt should not come thats our motive here. You need to either use ssh or use
git config credential.helper store. Check this out here.I am using credential store as i am the only one accessing that server.
Now start the script using node or pm2.
If you are using nginx , create a proxy pass for it. You just need to open the port 8080 for communication.

That's it . Your are done π.
You can find me on other platforms π