Skip to content

Commit 198768c

Browse files
committed
update
1 parent e1ca134 commit 198768c

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ jobs:
1919
- name: Detect changed packages
2020
id: set-matrix
2121
run: |
22-
if git rev-parse HEAD~1 > /dev/null 2>&1; then
23-
BASE_SHA=$(git rev-parse HEAD~1)
22+
# 获取最后一次成功运行的提交SHA或默认为一个空树
23+
git fetch origin refs/tags/last-deploy 2>/dev/null || true
24+
if git rev-parse -q --verify refs/tags/last-deploy >/dev/null; then
25+
BASE_SHA=$(git rev-parse refs/tags/last-deploy)
26+
echo "Using last successful deploy tag as base: $BASE_SHA"
2427
else
25-
BASE_SHA=$(git hash-object -t tree /dev/null)
28+
echo "No last-deploy tag found, using first commit in history"
29+
BASE_SHA=$(git rev-list --max-parents=0 HEAD)
2630
fi
2731
2832
HEAD_SHA=${{ github.sha }}
@@ -34,11 +38,14 @@ jobs:
3438
CHANGED_PACKAGES=()
3539
3640
for dir in $PACKAGE_DIRS; do
37-
if git diff --quiet $BASE_SHA $HEAD_SHA -- "$dir"; then
41+
if git diff --quiet --diff-filter=ACMRT $BASE_SHA $HEAD_SHA -- "$dir"; then
3842
echo "No changes in $dir"
3943
else
4044
echo "Detected changes in $dir"
41-
CHANGED_PACKAGES+=("$dir")
45+
# Only add first-level directories (no slashes in the path)
46+
if [[ "$dir" != *"/"* ]]; then
47+
CHANGED_PACKAGES+=("$dir")
48+
fi
4249
fi
4350
done
4451
@@ -104,4 +111,20 @@ jobs:
104111
sleep 5
105112
106113
# 发布
107-
npm publish --access public
114+
npm publish --access public
115+
116+
update-last-deploy-tag:
117+
runs-on: ubuntu-latest
118+
119+
steps:
120+
- name: Checkout code
121+
uses: actions/checkout@v3
122+
with:
123+
token: ${{ secrets.GHB_TOKEN }}
124+
125+
# 添加此步骤作为工作流的最后一步
126+
- name: Update last deploy tag
127+
if: success()
128+
run: |
129+
git tag -f last-deploy ${{ github.sha }}
130+
git push -f origin last-deploy

0 commit comments

Comments
 (0)