1
0
mirror of https://github.com/vdm-io/github-user.git synced 2024-12-05 00:33:13 +00:00

Added github personal access token for CLI use.

This commit is contained in:
Llewellyn van der Merwe 2021-07-13 21:40:59 +02:00
parent ba0f55b4b1
commit a3c97e0e04
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C

View File

@ -7,6 +7,7 @@ SSH_KEY=""
SSH_PUB="" SSH_PUB=""
GIT_USER="" GIT_USER=""
GIT_EMAIL="" GIT_EMAIL=""
GIT_TOKEN=""
SIGNKEY="" SIGNKEY=""
# check if we have options # check if we have options
@ -108,6 +109,22 @@ while :; do
echo 'ERROR: "--git-email" requires a non-empty option argument.' echo 'ERROR: "--git-email" requires a non-empty option argument.'
exit 1 exit 1
;; ;;
--git-token) # Takes an option argument; ensure it has been specified.
if [ "$2" ]; then
GIT_TOKEN=$2
shift
else
echo 'ERROR: "--git-token" requires a non-empty option argument.'
exit 1
fi
;;
--git-token=?*)
GIT_TOKEN=${1#*=} # Delete everything up to "=" and assign the remainder.
;;
--git-token=) # Handle the case of an empty --git-token=
echo 'ERROR: "--git-token" requires a non-empty option argument.'
exit 1
;;
*) # Default case: No more options, so break out of the loop. *) # Default case: No more options, so break out of the loop.
break ;; break ;;
esac esac
@ -149,6 +166,13 @@ if [ -z "${SSH_PUB}" ]; then
exit 1 exit 1
fi fi
# create a github config folder
mkdir -p ~/.github
# set the github personal access token for use in github CLI
# this can be an empty value as we don't always need this
echo "${GIT_TOKEN}" >~/.github/personal.access.token
chmod 400 ~/.github/personal.access.token
# move the keys into place (check the type!) # move the keys into place (check the type!)
echo "${SSH_KEY}" >~/.ssh/id_ed25519 echo "${SSH_KEY}" >~/.ssh/id_ed25519
echo "${SSH_PUB}" >~/.ssh/id_ed25519.pub echo "${SSH_PUB}" >~/.ssh/id_ed25519.pub