restructure: flatten scripts dirs, remove roster, update SKILL.md
This commit is contained in:
49
git-hangman-lab/scripts/repo-add-collaborators
Executable file
49
git-hangman-lab/scripts/repo-add-collaborators
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get the directory where this script is located
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
# Get username from ego-mgr
|
||||
username=$(ego-mgr get default-username)
|
||||
|
||||
# Check if username is provided
|
||||
if [[ -z "$username" ]]; then
|
||||
echo "Error: default-username not set in ego-mgr, please contact ard"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--repo)
|
||||
repo="$2"
|
||||
shift 2
|
||||
;;
|
||||
--user)
|
||||
user="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if user and repo are provided
|
||||
if [[ -z "$user" || -z "$repo" ]]; then
|
||||
echo "Usage: $0 --user <user> --repo <repo>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if git-access-token exists
|
||||
if ! secret-mgr list | grep -q "git-access-token"; then
|
||||
echo "generate your access token first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
owner=$(secret-mgr get-username --key git)
|
||||
token=$(secret-mgr get-secret --key git-access-token)
|
||||
|
||||
# Execute
|
||||
curl -X PUT -H "Authorization: token $token" -H "Content-Type: application/json" -d '{"permission":"write"}' "https://git.hangman-lab.top/api/v1/repos/$owner/$repo/collaborators/$user"
|
||||
Reference in New Issue
Block a user