I have a private GitHub repository that is owned by an organization. I want to pull the repository automatically after pushing to it. The webhook is already working, and I receive the event, but now I am stuck at the part where I pull the repository.
I have done research on this subject, however, I was unable to find a solution.
const util = require('util');
const exec = util.promisify(require('child_process').exec);
(async () => {
const { stdout, stderr } = await exec('git pull https://<token>@github.com/<username>/your_repo.git', {cwd: '/path/to/your_repo'})
console.log(stderr, stdout)
})()
You can generate a personal access token with clone and pull permission from here: https://github.com/settings/tokens