Gitlab webhooks not working due to shell script permission

Gitlab webhooks not working due to shell script permission

Using laravel 5.6. I'm trying to set up a webhook on gitlab, to make a git pull on push events. I've created a post route, added controller and method, that launches a shell script:

Using laravel 5.6. I'm trying to set up a webhook on gitlab, to make a git pull on push events. I've created a post route, added controller and method, that launches a shell script:

use Symfony\Component\Process\Process;

class WebhookController extends Controller
{
    public function handle(Request $request) {
        $root_path = base_path();
        $process = Process::fromShellCommandline('cd ' . $root_path . '; ./deploy.sh');
        $process->run(function($type, $buffer) {
            echo $buffer;
        });
    }
}

Shell script itself contains just a one line:

#!/bin/sh

git pull

But in gitlab's request details, i see an error after a push:

error: cannot open .git/FETCH_HEAD: Permission denied

I already chmod 777 deploy.sh, but i guess it tries to launch that script from different user? If i launch the script from my user, it just works (i'm using ssh key without a password).

UPDATE

I did sudo chown -R $USER:www-data . - now it doesn't show an error with permissions, except the one:

Could not create directory '/var/www/.ssh'.
Host key verification failed.
fatal: Could not read from remote repository.

It's trying to make a git pull using www-data user (i checked with whoami), so it doesn't have a right ssh key, how can i switch to my USERNAME?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Git It? How to use Git and Github

Learn how to use Git and Github 🐙🐱 Contributing to open-source is satisfying on many levels. Not only does it validate your skills for recruiters, but it leads to higher quality software that empowers developers to build better products. But submitting your first pull request on GitHub can be intimidating. The goal of this guide is to give you a clear set of steps for contributing any OS project

Git Tutorial For Beginners - Git Full Course

In this Git tutorial for beginners will help you learn about the most popular source code management tool used in DevOps. First, you will understand what DevOps is with the help of a short animated video. Then, you will see an introduction to DevOps. You will understand how to install Git on windows, followed by Git Tutorial, along with the hands-on demo. You will get an idea about the various Git commands used for the project files. Finally, you will get learn some of the most important Git interview questions that you might face in any DevOps interview