update auto auth
This commit is contained in:
parent
851f7ac044
commit
2892a9f0b6
|
|
@ -4,8 +4,8 @@
|
||||||
HOOK_PATH=/home/gitea_CICD
|
HOOK_PATH=/home/gitea_CICD
|
||||||
|
|
||||||
# Git account (*)
|
# Git account (*)
|
||||||
GIT_USERNAME=<your_branch>
|
GIT_USERNAME=<your_username>
|
||||||
GIT_PASSWORD=<your_branch>
|
GIT_PASSWORD=<your_password>
|
||||||
GIT_REPOSITORY=<your_repository>
|
GIT_REPOSITORY=<your_repository>
|
||||||
# Example: https://gitea.nswteam.net/username/repo_name.git
|
# Example: https://gitea.nswteam.net/username/repo_name.git
|
||||||
GIT_BRANCH=<your_branch>
|
GIT_BRANCH=<your_branch>
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,13 @@
|
||||||
# Đường dẫn tới tệp index.js
|
# Đường dẫn tới tệp index.js
|
||||||
indexjs_path=$HOOK_PATH/index.js
|
indexjs_path=$HOOK_PATH/index.js
|
||||||
project_path=$HOOK_PATH
|
project_path=$HOOK_PATH
|
||||||
|
USERNAME=$(echo "$GIT_USERNAME" | sed 's/@/%40/g')
|
||||||
PASSWORD=$(echo "$GIT_PASSWORD" | 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" &&
|
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
|
if git ls-remote -q --exit-code "$REPOSITORY_AUTH" > /dev/null; then
|
||||||
echo -e "\e[32mOK: Repository $GIT_REPOSITORY exists\e[0m"
|
echo -e "\e[32mOK: Repository $GIT_REPOSITORY exists\e[0m"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue