-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (52 loc) · 1.7 KB
/
Copy pathdetect-deps.yml
File metadata and controls
66 lines (52 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Detect Deps
on:
push:
branches:
- master
paths:
- package.json
workflow_dispatch:
permissions:
contents: read
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true
ref: ${{ github.ref }}
- name: Detect
run: |
DEPS=("vitepress")
TARGET_FILE="package.json"
if git rev-parse HEAD~1 >/dev/null 2>&1; then
OLD_COMMIT="HEAD~1"
else
OLD_COMMIT="HEAD"
fi
changed_list=()
echo "Target file: $TARGET_FILE"
echo "Comparing with: $OLD_COMMIT"
for dep in "${DEPS[@]}"; do
old_content=$(git show "$OLD_COMMIT":"$TARGET_FILE" 2>/dev/null || echo '{}')
old_version=$(echo "$old_content" | jq -r --arg dep "$dep" '.dependencies[$dep] // .devDependencies[$dep] // empty')
new_version=$(jq -r --arg dep "$dep" '.dependencies[$dep] // .devDependencies[$dep] // empty' "$TARGET_FILE")
echo "Checking $dep..."
echo "Old: $old_version"
echo "New: $new_version"
if [ "$old_version" != "$new_version" ]; then
echo "➡ $dep version changed!"
changed_list+=("$dep")
fi
done
if [ ${#changed_list[@]} -eq 0 ]; then
echo "No dependencies changed. Stopping workflow."
exit 1 # failure
fi
echo "Changed dependencies: ${changed_list[*]}"
echo "Dependencies changed. Starting next workflow."
exit 0 # success