Skip to content

Commit 2f98a2d

Browse files
Optimizations
1 parent eee93a8 commit 2f98a2d

1 file changed

Lines changed: 19 additions & 70 deletions

File tree

.github/workflows/deps.yaml

Lines changed: 19 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -6,113 +6,62 @@ name: Dependency Updates
66

77
on:
88
push:
9-
paths:
10-
- "pom.xml"
119
pull_request:
12-
paths:
13-
- "pom.xml"
1410
workflow_dispatch:
15-
schedule:
16-
- cron: "0 6 * * 1" # weekly fallback (Monday)
11+
schedule:
12+
- cron: "0 6 * * 1"
1713

1814
jobs:
1915
check-dependencies:
2016
runs-on: ubuntu-latest
2117

2218
steps:
23-
- name: Checkout repo
24-
uses: actions/checkout@v6
19+
- uses: actions/checkout@v6
2520

26-
- name: Set up Java
27-
uses: actions/setup-java@v5
21+
- uses: actions/setup-java@v5
2822
with:
2923
distribution: temurin
3024
java-version: 17
3125

32-
- name: Check if pom.xml changed
33-
id: changes
34-
uses: dorny/paths-filter@v4
35-
with:
36-
filters: |
37-
pom:
38-
- 'pom.xml'
39-
40-
- name: Run Maven (minor updates only)
41-
if: steps.changes.outputs.pom == 'true'
26+
- name: Run dependency check and publish table
4227
run: |
4328
mvn versions:display-dependency-updates \
4429
-DallowMajorUpdates=false \
4530
-DprocessDependencyManagement=true \
46-
| tee minor-updates.txt
31+
| tee minor.txt
4732
48-
- name: Run Maven (all updates)
49-
if: steps.changes.outputs.pom == 'true'
50-
run: |
5133
mvn versions:display-dependency-updates \
5234
-DallowMajorUpdates=true \
5335
-DprocessDependencyManagement=true \
54-
| tee all-updates.txt
55-
56-
- name: Generate HTML report
57-
if: steps.changes.outputs.pom == 'true'
58-
run: |
59-
echo "<html><head><style>
60-
body { font-family: Arial, sans-serif; }
61-
table { border-collapse: collapse; width: 100%; }
62-
th, td { border: 1px solid #ddd; padding: 8px; }
63-
th { background-color: #f2f2f2; text-align: left; }
64-
tr:nth-child(even) { background-color: #f9f9f9; }
65-
</style></head><body>" > report.html
66-
67-
echo "<h1>Dependency Updates</h1>" >> report.html
36+
| tee all.txt
6837
69-
# Also prepare summary (GitHub UI)
7038
echo "# Dependency Updates" >> $GITHUB_STEP_SUMMARY
7139
7240
parse_file () {
7341
FILE=$1
7442
TITLE=$2
7543
76-
# HTML
77-
echo "<h2>$TITLE</h2>" >> report.html
78-
echo "<table>" >> report.html
79-
echo "<tr><th>GroupId</th><th>ArtifactId</th><th>Current</th><th>Latest</th></tr>" >> report.html
80-
81-
# Summary (Markdown)
8244
echo "## $TITLE" >> $GITHUB_STEP_SUMMARY
8345
echo "" >> $GITHUB_STEP_SUMMARY
8446
echo "| GroupId | ArtifactId | Current | Latest |" >> $GITHUB_STEP_SUMMARY
8547
echo "|---------|------------|---------|--------|" >> $GITHUB_STEP_SUMMARY
8648
87-
grep -- "->" "$FILE" | sed 's/^\[INFO\]\s*//' | while read -r line; do
88-
# Extract groupId:artifactId
89-
GA=$(echo "$line" | sed -E 's/^([a-zA-Z0-9_.-]+:[a-zA-Z0-9_.-]+).*/\1/')
90-
91-
GROUP=$(echo "$GA" | cut -d: -f1)
92-
ARTIFACT=$(echo "$GA" | cut -d: -f2)
49+
grep -- "->" "$FILE" \
50+
| sed 's/^\[INFO\]\s*//' \
51+
| while read -r line; do
9352
94-
# Extract versions (last "X -> Y" in line)
95-
CURRENT=$(echo "$line" | sed -E 's/.* ([0-9A-Za-z.\-]+) -> .*/\1/')
96-
LATEST=$(echo "$line" | sed -E 's/.* -> ([0-9A-Za-z.\-]+).*/\1/')
53+
GA=$(echo "$line" | sed -E 's/^([a-zA-Z0-9_.-]+:[a-zA-Z0-9_.-]+).*/\1/')
54+
GROUP=$(echo "$GA" | cut -d: -f1)
55+
ARTIFACT=$(echo "$GA" | cut -d: -f2)
9756
98-
echo "<tr><td>$GROUP</td><td>$ARTIFACT</td><td>$CURRENT</td><td>$LATEST</td></tr>" >> report.html
99-
echo "| $GROUP | $ARTIFACT | $CURRENT | $LATEST |" >> $GITHUB_STEP_SUMMARY
100-
done
57+
CURRENT=$(echo "$line" | sed -E 's/.* ([0-9A-Za-z.\-]+) -> .*/\1/')
58+
LATEST=$(echo "$line" | sed -E 's/.* -> ([0-9A-Za-z.\-]+).*/\1/')
10159
102-
echo "</table>" >> report.html
103-
echo "" >> report.html
60+
echo "| $GROUP | $ARTIFACT | $CURRENT | $LATEST |" >> $GITHUB_STEP_SUMMARY
61+
done
10462
10563
echo "" >> $GITHUB_STEP_SUMMARY
10664
}
10765
108-
parse_file minor-updates.txt "Minor / Patch Updates Only"
109-
parse_file all-updates.txt "All Updates (Including Major)"
110-
111-
echo "</body></html>" >> report.html
112-
113-
- name: Upload report
114-
if: steps.changes.outputs.pom == 'true'
115-
uses: actions/upload-artifact@v7
116-
with:
117-
name: dependency-update-report
118-
path: report.html
66+
parse_file minor.txt "Minor / Patch Updates Only"
67+
parse_file all.txt "All Updates (Including Major)"

0 commit comments

Comments
 (0)