forked from joseph/gitea_CICD
update README, atuo auth git
This commit is contained in:
parent
c112c4138d
commit
7ad0b8b385
|
|
@ -5,10 +5,8 @@
|
|||
### 1) Clone project to your server
|
||||
|
||||
```sh
|
||||
git clone https://<USERNAME>:<PASSWORD>@gitea.nswteam.net/joseph/gitea_CICD.git
|
||||
git clone https://gitea.nswteam.net/joseph/gitea_CICD.git
|
||||
```
|
||||
- Get username:
|
||||
<div><img src="https://i.ibb.co/pLR2BjH/image.png" alt="getUsername" width="300"></div>
|
||||
|
||||
### 2) Access the folder you just cloned
|
||||
|
||||
|
|
@ -39,6 +37,9 @@ Copy environment file
|
|||
|
||||
### 5) Fill in environment variables (\*)
|
||||
|
||||
- Git username:
|
||||
<div><img src="https://i.ibb.co/pLR2BjH/image.png" alt="getUsername" width="300"></div>
|
||||
|
||||
root@root#
|
||||
```sh
|
||||
nano service_run/giteaService.conf
|
||||
|
|
|
|||
19
install.sh
19
install.sh
|
|
@ -13,7 +13,7 @@ if [ -d "/etc/systemd/system" ]; then
|
|||
echo -e "|***** \e[33mUPDATE ENVIRONMENT\e[0m *****|"
|
||||
echo "|------------------------------|"
|
||||
echo ""
|
||||
|
||||
|
||||
find $pwd_install/service -type f -not -name "giteaService.conf" -exec cp {} $pwd_install/service_run \;
|
||||
|
||||
sleep 2 &&
|
||||
|
|
@ -33,6 +33,7 @@ if [ -d "/etc/systemd/system" ]; then
|
|||
echo -e "* \e[32mEXEC_FILE\e[0m *" &&
|
||||
echo ""
|
||||
sleep 1 &&
|
||||
|
||||
systemctl stop giteaHook.service
|
||||
|
||||
input_file="$pwd_install/service_run/giteaService.conf" &&
|
||||
|
|
@ -55,8 +56,24 @@ if [ -d "/etc/systemd/system" ]; then
|
|||
echo -e "\e[32mOK: $path exists\e[0m"
|
||||
sleep 1
|
||||
fi
|
||||
else
|
||||
if [[ $line == *"REPOSITORY"* ]]; then
|
||||
path="${line#*=}"
|
||||
if git ls-remote -q --exit-code "$path" > /dev/null; then
|
||||
echo -e "\e[32mOK: Repository $path exists\e[0m"
|
||||
sleep 1
|
||||
else
|
||||
echo ""
|
||||
echo -e "\e[41mError: Repository $path not exists.\e[0m"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done <"$input_file" &&
|
||||
|
||||
|
||||
|
||||
cp $pwd_install/service_run/giteaHook.service /etc/systemd/system/giteaHook.service &&
|
||||
echo "" &&
|
||||
echo -e "* \e[32mCopy service file\e[0m *" &&
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@
|
|||
HOOK_PATH=/home/gitea_CICD
|
||||
|
||||
# Git account (*)
|
||||
GIT_USERNAME=<your_branch>
|
||||
GIT_PASSWORD=<your_branch>
|
||||
GIT_REPOSITORY=<your_repository>
|
||||
# Example: https://gitea.nswteam.net/username/repo_name.git
|
||||
GIT_BRANCH=<your_branch>
|
||||
|
||||
# Port of server (*)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@
|
|||
# Đường dẫn tới tệp index.js
|
||||
indexjs_path=$HOOK_PATH/index.js
|
||||
project_path=$HOOK_PATH
|
||||
REPOSITORY_AUTH="https://$GIT_USERNAME:$GIT_PASSWORD@$(echo $GIT_REPOSITORY | sed 's#https://##')"
|
||||
|
||||
cd "$PROJECT_PATH" &&
|
||||
SET_ORIGIN=$(git remote set-url origin $REPOSITORY_AUTH)
|
||||
echo "$SET_ORIGIN"
|
||||
|
||||
# Kiểm tra xem Node.js đã cài đặt chưa
|
||||
if ! command -v node &> /dev/null; then
|
||||
|
|
@ -34,3 +39,4 @@ if [ -f "$indexjs_path" ]; then
|
|||
else
|
||||
echo -e "\e[31mFile $indexjs_path not exists\e[0m"
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue