ci: 修复 GitHub 仓库为空时 clone 失败的问题
All checks were successful
TDevOpsCICD / build-kit (push) Successful in 5m27s
All checks were successful
TDevOpsCICD / build-kit (push) Successful in 5m27s
This commit is contained in:
parent
97c3b439fc
commit
297c2366f2
@ -122,9 +122,18 @@ jobs:
|
||||
EOF
|
||||
cat website/static/data/kit.json
|
||||
URL="https://x-access-token:${GH_TOKEN}@github.com/${GH_OWNER}/${GH_REPO}.git"
|
||||
BRANCH="${GH_BRANCH:-main}"
|
||||
rm -rf /tmp/website-pub
|
||||
git clone --depth 1 --branch "${GH_BRANCH:-main}" "${URL}" /tmp/website-pub
|
||||
if git clone --depth 1 --branch "$BRANCH" "${URL}" /tmp/website-pub 2>/dev/null; then
|
||||
cp -a website/. /tmp/website-pub/
|
||||
else
|
||||
rm -rf /tmp/website-pub
|
||||
mkdir -p /tmp/website-pub
|
||||
cd /tmp/website-pub
|
||||
git init -b "$BRANCH"
|
||||
git remote add origin "${URL}"
|
||||
cp -a "$GITHUB_WORKSPACE/website/." .
|
||||
fi
|
||||
cd /tmp/website-pub
|
||||
git config user.name "kit-ci"
|
||||
git config user.email "kit-ci@honor3.com"
|
||||
@ -133,5 +142,5 @@ jobs:
|
||||
echo "No website changes to publish"
|
||||
else
|
||||
git commit -m "release(website): publish kit ${REF_NAME}"
|
||||
git push origin "${GH_BRANCH:-main}"
|
||||
git push origin "$BRANCH"
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user