@@ -78,23 +78,36 @@ jobs:
7878 - name : Fetch and checkout each branch (shallow)
7979 if : env.SKIP_DEPLOY != 'true'
8080 run : |
81- # TODO: Let's change this(only needed branch)
8281 # git clone git@github.com:LetMeFly666/LeetCode.git --depth=1
8382 # cd LeetCode
8483 # git rev-list --count HEAD
85- git fetch --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
86- for branch in $(git branch -r | grep -v '\->'); do
87- local_branch="${branch#origin/}"
88- if [[ "$local_branch" =~ ^[0-9] ]] || [[ "$local_branch" == "From_GitCode_CSDN" ]]; then
89- echo "Skipping branch $local_branch"
84+ branches=(
85+ website
86+ website_Static
87+ website_modifyTime
88+ )
89+ # 非 website_testMaster 才需要 master
90+ if [ "${GITHUB_REF}" != "refs/heads/website_testMaster" ]; then
91+ branches+=(master)
92+ else
93+ echo "Triggered by website_testMaster, skip fetching master"
94+ fi
95+
96+ echo "Branches to process: ${branches[*]}"
97+
98+ # 只 fetch 需要的分支
99+ for branch in "${branches[@]}"; do
100+ # 如果本地已存在,直接跳过
101+ if git show-ref --quiet "refs/heads/$branch"; then
102+ echo "Local branch $branch already exists, skipping fetch/checkout"
90103 continue
91104 fi
92- if ! git show-ref --quiet "refs/heads/$local_branch"; then
93- echo "Setting branch $local_branch "
94- git switch -c $local_branch origin/$local_branch
95- else
96- echo "Branch $local_branch already exists, skipping... "
97- fi
105+
106+ echo "Fetching branch $branch "
107+ git fetch --depth=1 origin "$branch"
108+
109+ echo "Checking out branch $branch "
110+ git switch -c "$branch" "origin/$branch"
98111 done
99112
100113 if [ "${GITHUB_REF}" = "refs/heads/website_testMaster" ]; then
@@ -185,11 +198,12 @@ jobs:
185198 echo "Commit time: $commit_time"
186199
187200 has_modified=false
188- while read -r status file; do
201+ while IFS= read -r -d '' status && IFS= read -r -d '' file; do
189202 [[ "$file" == Solutions/*.md ]] || continue
190203
191204 filename=$(basename "$file")
192205 has_modified=true
206+ echo "($status)$filename"
193207
194208 case "$status" in
195209 A|M)
@@ -206,7 +220,7 @@ jobs:
206220 'del(.[$k])')
207221 ;;
208222 esac
209- done < <(git diff --name-status HEAD~1 HEAD)
223+ done < <(git diff --name-status -z HEAD~1 HEAD)
210224
211225 if [ "$has_modified" = false ]; then
212226 echo "no modified Solutions/*.md files"
@@ -236,7 +250,7 @@ jobs:
236250 file_name=$(echo "$line" | jq -r 'keys[0]')
237251 file_time=$(echo "$line" | jq -r '.[keys[0]]')
238252 touch -d "$file_time" "Solutions/$file_name"
239- echo "set Solutions/$file_name -> $file_time"
253+ # echo "set Solutions/$file_name -> $file_time"
240254 done < <(jq -c 'to_entries | map({(.key): .value}) | .[]' "$json_file")
241255
242256 - name : Install hexo and init
@@ -271,8 +285,8 @@ jobs:
271285
272286 # sub theme: 明日方舟arknights
273287 cp -a ../hexoWorkspace ../hexoWorkspace_arknights
274- ls -l ../hexoWorkspace/source/_posts
275- ls -l ../hexoWorkspace_arknights/source/_posts
288+ # ls -l ../hexoWorkspace/source/_posts
289+ # ls -l ../hexoWorkspace_arknights/source/_posts
276290
277291 - name : Install dependencies
278292 if : env.SKIP_DEPLOY != 'true'
@@ -319,18 +333,16 @@ jobs:
319333 - name : Modify sitemap
320334 if : env.SKIP_DEPLOY != 'true'
321335 run : |
322- # TODO: Let's change this
323- # TODO: Let's change tag orders
324336 echo "" > ../hexoWorkspace/public/sitemap.txt # 主站优先
325337 sed 's/theme\/arknights\///g' ../hexoWorkspace/public/theme/arknights/sitemap.txt >> ../hexoWorkspace/public/sitemap.txt
326- cat ../hexoWorkspace/public/theme/arknights/sitemap.txt >> ../hexoWorkspace/public/sitemap.txt
338+ # cat ../hexoWorkspace/public/theme/arknights/sitemap.txt >> ../hexoWorkspace/public/sitemap.txt
327339 # echo "https://blog.letmefly.xyz/theme/arknights/sitemap.txt" >> ../hexoWorkspace/public/sitemap.txt
328340
329341 - name : Push to github
330342 if : env.SKIP_DEPLOY != 'true'
331343 run : |
332344 git checkout website
333- ls -la
345+ # ls -la
334346 cp -r .git ../hexoWorkspace/public
335347 cd ../hexoWorkspace/public
336348 # DECODED_MESSAGE=$(echo "$ENCODED_MESSAGE" | base64 --decode)
0 commit comments