update auto auth

This commit is contained in:
Joseph Le 2023-10-13 17:58:07 +11:00
parent 851f7ac044
commit 2892a9f0b6
2 changed files with 6 additions and 4 deletions

View File

@ -4,8 +4,8 @@
HOOK_PATH=/home/gitea_CICD
# Git account (*)
GIT_USERNAME=<your_branch>
GIT_PASSWORD=<your_branch>
GIT_USERNAME=<your_username>
GIT_PASSWORD=<your_password>
GIT_REPOSITORY=<your_repository>
# Example: https://gitea.nswteam.net/username/repo_name.git
GIT_BRANCH=<your_branch>

View File

@ -3,11 +3,13 @@
# Đường dẫn tới tệp index.js
indexjs_path=$HOOK_PATH/index.js
project_path=$HOOK_PATH
USERNAME=$(echo "$GIT_USERNAME" | sed 's/@/%40/g')
PASSWORD=$(echo "$GIT_PASSWORD" | sed 's/@/%40/g')
REPOSITORY_AUTH="https://$GIT_USERNAME:$PASSWORD@$(echo $GIT_REPOSITORY | sed 's#https://##')"
REPOSITORY_AUTH="https://$USERNAME:$PASSWORD@$(echo $GIT_REPOSITORY | sed 's#https://##')"
cd "$PROJECT_PATH" &&
SET_ORIGIN=$(git remote set-url origin $REPOSITORY_AUTH)
git config --global --add safe.directory $PROJECT_PATH &&
SET_ORIGIN=$(git remote set-url origin $REPOSITORY_AUTH) &&
if git ls-remote -q --exit-code "$REPOSITORY_AUTH" > /dev/null; then
echo -e "\e[32mOK: Repository $GIT_REPOSITORY exists\e[0m"