Search code examples
javascriptgitformsgithubgithub-api

Trigger git commit using form response


is there a way that I can trigger a git commit when a user submits their js form? I want to include the data submitted in the form in the description of the commit on github. I tried using multiple frameworks, but I didn't succeed.

Stack:

  • Im using bootstrap 5.1 for the ui.
  • Deploying on a static site on render.com

Solution

  • if you are using PHP, you can use the exec to execute a command.

    Basically, you can write a REST API that will run the exec functions.

    For example, let's use Laravel

    Route::post('commit', function(Request $request) {
      exec('cd /to/your/folder';
      exec('git add .');
      exec('git commit -m "'.$request->commitMessage.'"');
      exec('git push origin master');
    });