#!/usr/bin/perl use strict; use warnings; use Git::Repository; use File::Spec; # Hard-coded values for GitLab access my $repo_path = '/home/fritz/Desktop/dl2/repack'; # Path to your local git repository my $commit_msg = 'Automated commit from Perl script'; my $branch = 'main'; my $git_user = '@redacted'; my $git_email = 'redacted@gmail.com'; my $remote_name = 'origin'; my $remote_url = 'git@gitlab.com:aardvark/hja.git'; # Update with your GitLab repo URL # Set up Git repository object my $repo = Git::Repository->new( work_tree => $repo_path ); # Set user configuration $repo->run( config => 'user.name', $git_user ); $repo->run( config => 'user.email', $git_email ); # Add all changes to the staging area $repo->run( add => '.' ); # Commit changes $repo->run( commit => '-m', $commit_msg ); # Check if the remote exists, add if not my $remotes = $repo->run( 'remote' ); if ($remotes !~ /$remote_name/) { $repo->run( remote => 'add', $remote_name, $remote_url ); } # Push changes to the remote repository $repo->run( push => $remote_name, $branch ); print "Changes pushed to GitLab successfully.\n";