-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
163 lines (138 loc) · 4.85 KB
/
action.yml
File metadata and controls
163 lines (138 loc) · 4.85 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: 'depfresh - Dependency Freshness Check'
description: 'Check npm dependencies for available updates with structured JSON output'
author: 'Vibe Code'
branding:
icon: 'package'
color: 'green'
inputs:
mode:
description: 'Version range mode: default, major, minor, patch, latest, newest, next'
required: false
default: 'default'
write:
description: 'Write updated versions to package files'
required: false
default: 'false'
fail-on-outdated:
description: 'Exit 1 if outdated dependencies are found (ignored when write is true)'
required: false
default: 'true'
include:
description: 'Comma-separated list of package name patterns to include'
required: false
default: ''
exclude:
description: 'Comma-separated list of package name patterns to exclude'
required: false
default: ''
recursive:
description: 'Recursively scan workspace packages'
required: false
default: 'true'
working-directory:
description: 'Directory to run depfresh in'
required: false
default: '.'
node-version:
description: 'Node.js version to use'
required: false
default: '24'
extra-args:
description: 'Additional CLI flags passed directly to depfresh'
required: false
default: ''
outputs:
json:
description: 'Full JSON output from depfresh'
value: ${{ steps.parse.outputs.json }}
outdated-count:
description: 'Number of outdated dependencies found'
value: ${{ steps.parse.outputs.outdated-count }}
exit-code:
description: 'Raw exit code from depfresh (0=up-to-date, 1=outdated, 2=error)'
value: ${{ steps.run.outputs.exit-code }}
has-updates:
description: 'Whether outdated dependencies were found (true/false)'
value: ${{ steps.parse.outputs.has-updates }}
runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- name: Install depfresh
shell: bash
run: npm install -g depfresh
- name: Run depfresh
id: run
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
DEPFRESH_ARGS="--output json"
if [ "${{ inputs.mode }}" != "default" ]; then
DEPFRESH_ARGS="$DEPFRESH_ARGS --mode ${{ inputs.mode }}"
fi
if [ "${{ inputs.write }}" = "true" ]; then
DEPFRESH_ARGS="$DEPFRESH_ARGS --write"
fi
if [ "${{ inputs.fail-on-outdated }}" = "true" ] && [ "${{ inputs.write }}" != "true" ]; then
DEPFRESH_ARGS="$DEPFRESH_ARGS --fail-on-outdated"
fi
if [ "${{ inputs.recursive }}" = "false" ]; then
DEPFRESH_ARGS="$DEPFRESH_ARGS --no-recursive"
fi
if [ -n "${{ inputs.include }}" ]; then
DEPFRESH_ARGS="$DEPFRESH_ARGS --include ${{ inputs.include }}"
fi
if [ -n "${{ inputs.exclude }}" ]; then
DEPFRESH_ARGS="$DEPFRESH_ARGS --exclude ${{ inputs.exclude }}"
fi
if [ -n "${{ inputs.extra-args }}" ]; then
DEPFRESH_ARGS="$DEPFRESH_ARGS ${{ inputs.extra-args }}"
fi
DEPFRESH_OUTPUT=$(mktemp)
EXIT_CODE=0
depfresh $DEPFRESH_ARGS > "$DEPFRESH_OUTPUT" || EXIT_CODE=$?
echo "exit-code=$EXIT_CODE" >> "$GITHUB_OUTPUT"
echo "output-file=$DEPFRESH_OUTPUT" >> "$GITHUB_OUTPUT"
if [ "$EXIT_CODE" -eq 2 ]; then
echo "::error::depfresh encountered a fatal error (exit code 2)"
cat "$DEPFRESH_OUTPUT"
exit 2
fi
- name: Parse outputs
id: parse
shell: bash
run: |
OUTPUT_FILE="${{ steps.run.outputs.output-file }}"
EXIT_CODE="${{ steps.run.outputs.exit-code }}"
if [ ! -s "$OUTPUT_FILE" ]; then
echo "json={}" >> "$GITHUB_OUTPUT"
echo "outdated-count=0" >> "$GITHUB_OUTPUT"
echo "has-updates=false" >> "$GITHUB_OUTPUT"
exit 0
fi
JSON_CONTENT=$(cat "$OUTPUT_FILE")
# Store JSON output (escape for GitHub Actions)
{
echo "json<<DEPFRESH_JSON_EOF"
echo "$JSON_CONTENT"
echo "DEPFRESH_JSON_EOF"
} >> "$GITHUB_OUTPUT"
# Extract outdated count from summary.total
OUTDATED_COUNT=$(echo "$JSON_CONTENT" | jq -r '.summary.total // 0')
echo "outdated-count=$OUTDATED_COUNT" >> "$GITHUB_OUTPUT"
if [ "$OUTDATED_COUNT" -gt 0 ]; then
echo "has-updates=true" >> "$GITHUB_OUTPUT"
else
echo "has-updates=false" >> "$GITHUB_OUTPUT"
fi
# Clean up temp file
rm -f "$OUTPUT_FILE"
- name: Handle fail-on-outdated
if: ${{ steps.run.outputs.exit-code == '1' && inputs.fail-on-outdated == 'true' && inputs.write != 'true' }}
shell: bash
run: |
echo "::warning::depfresh found ${{ steps.parse.outputs.outdated-count }} outdated dependencies"
exit 1