-
Notifications
You must be signed in to change notification settings - Fork 24
387 lines (325 loc) · 14.9 KB
/
update-skill-pack.yml
File metadata and controls
387 lines (325 loc) · 14.9 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
name: Update n8n Skill Pack
on:
schedule:
# Run every Sunday at 00:00 UTC
- cron: '0 0 * * 0'
workflow_dispatch: # Allow manual trigger
inputs:
version-bump:
description: 'Version bump type'
required: true
default: 'auto'
type: choice
options:
- auto
- patch
- minor
- major
permissions:
contents: write
pull-requests: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Update n8n to latest
id: update_n8n
run: |
# 記錄更新前的版本
OLD_N8N=$(jq -r '.dependencies["n8n"]' package.json | sed 's/\^//')
# 更新 n8n 主套件到最新版本
npm install n8n@latest
# 記錄更新後的版本
NEW_N8N=$(jq -r '.dependencies["n8n"]' package.json | sed 's/\^//')
echo "old_version=$OLD_N8N" >> $GITHUB_OUTPUT
echo "new_version=$NEW_N8N" >> $GITHUB_OUTPUT
if [ "$OLD_N8N" != "$NEW_N8N" ]; then
echo "n8n_updated=true" >> $GITHUB_OUTPUT
echo "n8n updated: v$OLD_N8N → v$NEW_N8N"
else
echo "n8n_updated=false" >> $GITHUB_OUTPUT
echo "n8n is already up to date: v$NEW_N8N"
fi
- name: Update other n8n packages if n8n was updated
if: steps.update_n8n.outputs.n8n_updated == 'true'
run: |
echo "n8n was updated, updating related packages..."
npm install n8n-core@latest n8n-workflow@latest n8n-nodes-base@latest @n8n/n8n-nodes-langchain@latest
- name: Check n8n packages version changes
id: check_version
run: |
# Read old versions (from main branch)
git fetch origin main
OLD_N8N=$(git show origin/main:package.json | jq -r '.dependencies["n8n"]' | sed 's/\^//')
OLD_N8N_CORE=$(git show origin/main:package.json | jq -r '.dependencies["n8n-core"]' | sed 's/\^//')
OLD_N8N_NODES_BASE=$(git show origin/main:package.json | jq -r '.dependencies["n8n-nodes-base"]' | sed 's/\^//')
OLD_N8N_LANGCHAIN=$(git show origin/main:package.json | jq -r '.dependencies["@n8n/n8n-nodes-langchain"]' | sed 's/\^//')
# Read new versions (after update)
NEW_N8N=$(jq -r '.dependencies["n8n"]' package.json | sed 's/\^//')
NEW_N8N_CORE=$(jq -r '.dependencies["n8n-core"]' package.json | sed 's/\^//')
NEW_N8N_NODES_BASE=$(jq -r '.dependencies["n8n-nodes-base"]' package.json | sed 's/\^//')
NEW_N8N_LANGCHAIN=$(jq -r '.dependencies["@n8n/n8n-nodes-langchain"]' package.json | sed 's/\^//')
echo "old_n8n_version=$OLD_N8N" >> $GITHUB_OUTPUT
echo "new_n8n_version=$NEW_N8N" >> $GITHUB_OUTPUT
# Check if any n8n package has changed
VERSION_CHANGED=false
N8N_CHANGED=false
if [ "$OLD_N8N" != "$NEW_N8N" ]; then
VERSION_CHANGED=true
N8N_CHANGED=true
echo "n8n version changed: v$OLD_N8N → v$NEW_N8N"
fi
if [ "$OLD_N8N_CORE" != "$NEW_N8N_CORE" ]; then
VERSION_CHANGED=true
echo "n8n-core version changed: v$OLD_N8N_CORE → v$NEW_N8N_CORE"
fi
if [ "$OLD_N8N_NODES_BASE" != "$NEW_N8N_NODES_BASE" ]; then
VERSION_CHANGED=true
echo "n8n-nodes-base version changed: v$OLD_N8N_NODES_BASE → v$NEW_N8N_NODES_BASE"
fi
if [ "$OLD_N8N_LANGCHAIN" != "$NEW_N8N_LANGCHAIN" ]; then
VERSION_CHANGED=true
echo "@n8n/n8n-nodes-langchain version changed: v$OLD_N8N_LANGCHAIN → v$NEW_N8N_LANGCHAIN"
fi
echo "version_changed=$VERSION_CHANGED" >> $GITHUB_OUTPUT
echo "n8n_changed=$N8N_CHANGED" >> $GITHUB_OUTPUT
if [ "$VERSION_CHANGED" = false ]; then
echo "No n8n package version changes detected, skipping build"
fi
- name: Check if should update community packages
id: check_community
run: |
# Update community packages on the first Sunday of each month (day 1-7)
DAY_OF_MONTH=$(date +%d)
if [ "$DAY_OF_MONTH" -le 7 ]; then
echo "should_update=true" >> $GITHUB_OUTPUT
echo "First Sunday of the month, will update community packages"
else
echo "should_update=false" >> $GITHUB_OUTPUT
echo "Not the first Sunday of the month, skipping community packages update"
fi
- name: Update community packages
if: steps.check_community.outputs.should_update == 'true'
id: update_community
run: |
echo "Updating community packages from npm..."
npm run update:community
# Check if community packages changed
if [[ -n $(git diff config/community-packages.json) ]]; then
echo "community_updated=true" >> $GITHUB_OUTPUT
echo "Community packages updated"
else
echo "community_updated=false" >> $GITHUB_OUTPUT
echo "No community packages changes"
fi
- name: Determine if build is needed
id: need_build
run: |
VERSION_CHANGED="${{ steps.check_version.outputs.version_changed }}"
COMMUNITY_UPDATED="${{ steps.update_community.outputs.community_updated }}"
if [ "$VERSION_CHANGED" == "true" ] || [ "$COMMUNITY_UPDATED" == "true" ]; then
echo "need_build=true" >> $GITHUB_OUTPUT
echo "Build needed: n8n_changed=$VERSION_CHANGED, community_updated=$COMMUNITY_UPDATED"
else
echo "need_build=false" >> $GITHUB_OUTPUT
echo "No build needed"
fi
- name: Run full build
if: steps.need_build.outputs.need_build == 'true'
run: npm run build:full
- name: Validate output files
if: steps.need_build.outputs.need_build == 'true'
run: npm run validate
- name: Update website data
if: steps.need_build.outputs.need_build == 'true'
run: npm run update:website
- name: Determine version bump type
if: steps.need_build.outputs.need_build == 'true'
id: determine_bump
run: |
MANUAL_BUMP="${{ github.event.inputs.version-bump }}"
N8N_CHANGED="${{ steps.check_version.outputs.n8n_changed }}"
COMMUNITY_UPDATED="${{ steps.update_community.outputs.community_updated }}"
if [ "$MANUAL_BUMP" != "" ] && [ "$MANUAL_BUMP" != "auto" ]; then
# Manual trigger with specified version type
echo "bump_type=$MANUAL_BUMP" >> $GITHUB_OUTPUT
echo "Using manually specified version type: $MANUAL_BUMP"
elif [ "$N8N_CHANGED" == "true" ]; then
# Analyze n8n version change to determine bump type
OLD_N8N="${{ steps.check_version.outputs.old_n8n_version }}"
NEW_N8N="${{ steps.check_version.outputs.new_n8n_version }}"
# Parse version numbers (major.minor.patch)
IFS='.' read -r OLD_MAJOR OLD_MINOR OLD_PATCH <<< "$OLD_N8N"
IFS='.' read -r NEW_MAJOR NEW_MINOR NEW_PATCH <<< "$NEW_N8N"
# Determine bump type based on n8n version change
if [ "$NEW_MAJOR" != "$OLD_MAJOR" ]; then
echo "bump_type=major" >> $GITHUB_OUTPUT
echo "n8n major upgrade detected: v$OLD_N8N → v$NEW_N8N, using major version bump"
elif [ "$NEW_MINOR" != "$OLD_MINOR" ]; then
echo "bump_type=minor" >> $GITHUB_OUTPUT
echo "n8n minor upgrade detected: v$OLD_N8N → v$NEW_N8N, using minor version bump"
elif [ "$NEW_PATCH" != "$OLD_PATCH" ]; then
echo "bump_type=patch" >> $GITHUB_OUTPUT
echo "n8n patch upgrade detected: v$OLD_N8N → v$NEW_N8N, using patch version bump"
else
echo "bump_type=patch" >> $GITHUB_OUTPUT
echo "n8n version unchanged: v$NEW_N8N, using patch version bump"
fi
elif [ "$COMMUNITY_UPDATED" == "true" ]; then
# Only community packages updated, use patch
echo "bump_type=patch" >> $GITHUB_OUTPUT
echo "Community packages updated, using patch version bump"
else
# Only other n8n packages changed, use patch
echo "bump_type=patch" >> $GITHUB_OUTPUT
echo "Other n8n packages updated (n8n-core/n8n-nodes-base/n8n-nodes-langchain), using patch version bump"
fi
- name: Update package.json version
if: steps.need_build.outputs.need_build == 'true'
id: bump_version
run: |
CURRENT_VERSION=$(jq -r '.version' package.json)
BUMP_TYPE="${{ steps.determine_bump.outputs.bump_type }}"
# Parse version number
IFS='.' read -r -a version_parts <<< "$CURRENT_VERSION"
MAJOR="${version_parts[0]}"
MINOR="${version_parts[1]}"
PATCH="${version_parts[2]}"
# Bump version by type
case "$BUMP_TYPE" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
# Update package.json
jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp
mv package.json.tmp package.json
echo "old_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Version updated: $CURRENT_VERSION → $NEW_VERSION"
- name: Update README.md version statement
if: steps.check_version.outputs.n8n_changed == 'true'
run: |
N8N_VERSION="${{ steps.check_version.outputs.new_n8n_version }}"
sed -i "s/支援 n8n 版本:v[0-9.]\+/支援 n8n 版本:v${N8N_VERSION}/" README.md
echo "README.md updated with n8n version v${N8N_VERSION}"
- name: Check for changes
if: steps.need_build.outputs.need_build == 'true'
id: check_changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Changes detected"
else
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
fi
- name: Get change summary
if: steps.check_changes.outputs.has_changes == 'true'
id: get_summary
run: |
CHANGED_FILES=$(git diff --name-only | head -20)
echo "changed_files<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Generate PR title
if: steps.need_build.outputs.need_build == 'true'
id: pr_title
run: |
OLD_N8N="${{ steps.check_version.outputs.old_n8n_version }}"
NEW_N8N="${{ steps.check_version.outputs.new_n8n_version }}"
N8N_CHANGED="${{ steps.check_version.outputs.n8n_changed }}"
COMMUNITY_UPDATED="${{ steps.update_community.outputs.community_updated }}"
if [ "$N8N_CHANGED" == "true" ]; then
PR_TITLE="Auto update: n8n v${OLD_N8N} → v${NEW_N8N}"
elif [ "$COMMUNITY_UPDATED" == "true" ]; then
PR_TITLE="Auto update: community packages refresh"
else
PR_TITLE="Auto update: n8n v${NEW_N8N} data refresh"
fi
echo "title=$PR_TITLE" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.check_changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GH_PAT }}
commit-message: |
Update n8n skill pack data and website
Automatically update n8n node data, documentation, and website information
- n8n version: v${{ steps.check_version.outputs.new_n8n_version }}
- Skill pack version: ${{ steps.bump_version.outputs.old_version }} → ${{ steps.bump_version.outputs.new_version }}
- Community packages: ${{ steps.update_community.outputs.community_updated == 'true' && 'updated' || 'unchanged' }}
- Website data synchronized
Changed files:
${{ steps.get_summary.outputs.changed_files }}
branch: auto-update-skill-pack
delete-branch: true
title: ${{ steps.pr_title.outputs.title }}
body: |
## Auto Update n8n Skill Pack
This PR is automatically created by GitHub Actions with the latest n8n node data.
### Version Information
- n8n version: v${{ steps.check_version.outputs.new_n8n_version }}
- Skill pack version: ${{ steps.bump_version.outputs.old_version }} → ${{ steps.bump_version.outputs.new_version }}
- Version bump type: ${{ steps.determine_bump.outputs.bump_type }}
- Community packages updated: ${{ steps.update_community.outputs.community_updated == 'true' && 'Yes' || 'No' }}
### Updates
The following data has been automatically synchronized:
- Node count updated
- n8n version number updated
- Template count updated
- Community packages (top 30 from npm, monthly)
- Last update date refreshed
### Changes
```
${{ steps.get_summary.outputs.changed_files }}
```
### Checklist
- [ ] Check data integrity
- [ ] Verify Markdown format
- [ ] Confirm internal links work
- [ ] Test skill pack loading
- [ ] Verify version number
labels: |
auto-update
dependencies
- name: Update result notification
if: always()
run: |
NEED_BUILD="${{ steps.need_build.outputs.need_build }}"
HAS_CHANGES="${{ steps.check_changes.outputs.has_changes }}"
VERSION_CHANGED="${{ steps.check_version.outputs.version_changed }}"
COMMUNITY_UPDATED="${{ steps.update_community.outputs.community_updated }}"
echo "=== Update Summary ==="
echo "n8n packages changed: $VERSION_CHANGED"
echo "Community packages updated: $COMMUNITY_UPDATED"
echo "Build needed: $NEED_BUILD"
echo "Has changes: $HAS_CHANGES"
if [[ "$NEED_BUILD" == "false" ]]; then
echo "No updates needed"
elif [[ "$HAS_CHANGES" == "true" ]]; then
echo "Pull Request created, awaiting review"
else
echo "Build ran but no file changes detected"
fi