Alle 30 Artikel, WF2 veroeffentlicht direkt und schuetzt veroeffentlichte Beitraege

This commit is contained in:
2026-09-22 18:33:54 +02:00
parent 0c0fbe6208
commit 05d8488e4b
5 changed files with 275 additions and 98 deletions

19
build/wf2_deploy.py Normal file
View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
"""Spielt workflows/pruefen-und-importieren.json in n8n ein, Credentials und Webhook-IDs bleiben erhalten."""
import json, os, urllib.request
w = json.load(open('workflows/pruefen-und-importieren.json', encoding='utf-8'))
wid_ = json.load(open('build/workflow-ids.json'))['pruefen-und-importieren']
H = {'X-N8N-API-KEY': os.environ['N8N_API_KEY'], 'Content-Type': 'application/json'}
base = os.environ['N8N_BASE_URL'].rstrip('/') + '/api/v1/workflows/' + wid_
alt = json.load(urllib.request.urlopen(urllib.request.Request(base, headers=H)))
cred = {n['name']: n.get('credentials') for n in alt['nodes'] if n.get('credentials')}
hook = {n['name']: n.get('webhookId') for n in alt['nodes'] if n.get('webhookId')}
for n in w['nodes']:
if n['name'] in cred: n['credentials'] = cred[n['name']]
if n['name'] in hook: n['webhookId'] = hook[n['name']]
erlaubt = ('executionOrder', 'saveManualExecutions', 'callerPolicy', 'errorWorkflow', 'timezone',
'saveDataErrorExecution', 'saveDataSuccessExecution', 'saveExecutionProgress', 'executionTimeout')
body = {'name': alt['name'], 'nodes': w['nodes'], 'connections': w['connections'],
'settings': {k: v for k, v in (alt.get('settings') or {}).items() if k in erlaubt}}
d = json.load(urllib.request.urlopen(urllib.request.Request(base, data=json.dumps(body).encode(), headers=H, method='PUT')))
print('aktualisiert', d['id'], 'aktiv' if d['active'] else 'inaktiv', len(d['nodes']), 'Nodes')