4

We have a test rig (Linux machine) at my office. All employees can access the rig and we have private repositories hosted on GitHub. Also, each user account is authorized by SAML. Therefore, to perform any operation on those private repositories we need a personal access token. Right now everyone is using my personal access token. I made some big modifications and reached a point where whenever a user login to the rig, their personal access tokens will be added as an environment variable and it is their responsibility to logout so no one will be using their personal access token to perform any git operations. The problem is I don't know the command that uses this personal access token to push changes to the repository through a script.

I know how to push the changes to GitHub if the access tokens are cached in the machine. But trying to make it work with an environment variable. The end goal is to have anyone with personal access token authenticated shall work with the repositories.

#!/bin/bash

git init
git add .
git commit -a -m "$*"
REPOSITORY_URL=$(git config --get remote.origin.url)
REPOSITORY_NAME=$(echo $REPOSITORY_URL | sed 's/https\:\/\/github.com\/<ORGNAME>\///g')
git push ???????????
Venkatavaradhan
  • 139
  • 4
  • 13

0 Answers0