限时免费试用:欢迎注册 api.bigmodel.org ,快速体验大模型 API 接入服务。
当前位置:首页 >软件教程

云效+git部署可回滚

分类:软件教程时间:2024-10-17浏览:754

#!/bin/bash

REPO_URL="https://codeup.aliyun.com/66b1e3e339eec40a6d4bf3fe/test_yx.git"
REPO_DIR="/www/wwwroot/test-yx.test.90ckm.com"
NETRC_FILE=~/.netrc

if [ ! -f "$NETRC_FILE" ]; then
  cat < ~/.netrc
machine codeup.aliyun.com
login git账号例如34689347
password git密码
EOL
  chmod 600 ~/.netrc
fi  

git config --global user.name "34689347"
git config --global user.email "[email protected]"

if [ ! -d "$REPO_DIR" ]; then
  git clone $REPO_URL $REPO_DIR
  if [ $? -ne 0 ]; then
    echo "克隆失败"
    exit 1
  fi
fi

cd $REPO_DIR
git fetch ${REPO_URL}
DEFAULT_BRANCH=$(git remote show ${REPO_URL} | grep 'HEAD branch' | cut -d' ' -f5)
git checkout $DEFAULT_BRANCH
git pull ${REPO_URL} $DEFAULT_BRANCH

if [ ! -z "${CI_COMMIT_ID}" ]; then
  echo "检出: ${CI_COMMIT_ID}"
  FULL_COMMIT_ID=$(git rev-parse --verify ${CI_COMMIT_ID} 2>/dev/null)
  if [ $? -eq 0 ]; then
    git checkout ${FULL_COMMIT_ID}
  else
    echo "找不到"
    git log --oneline -n 10
    exit 1
  fi
fi
本站文章如未注明出处均为原创,转载请注明出处,如有侵权请邮件联系站长。
0/500
Share your thoughts respectfully.