-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (148 loc) · 5.31 KB
/
Copy pathmonthly-update.yml
File metadata and controls
165 lines (148 loc) · 5.31 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
name: n8n nodes catalog monthly update
on:
schedule:
# 1st of each month, 09:00 UTC
- cron: "0 9 1 * *"
workflow_dispatch:
inputs:
tag:
description: "n8n release tag (leave blank for latest)"
required: false
default: ""
jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install dependencies
run: pip install requests pyarrow huggingface_hub
- name: Run extraction
id: extract
env:
N8N_TAG: ${{ github.event.inputs.tag }}
run: |
if [ -n "$N8N_TAG" ]; then
python extract.py --tag "$N8N_TAG"
else
python extract.py
fi
- name: Check for data changes
id: diff
run: |
NEW_HASH=$(sha256sum nodes.json | cut -d' ' -f1)
echo "new_hash=$NEW_HASH" >> "$GITHUB_OUTPUT"
if python - <<'PY'
import sys
try:
from huggingface_hub import hf_hub_download
import os, hashlib
path = hf_hub_download(
repo_id="automatelab/n8n-nodes-catalog",
filename="nodes.json",
repo_type="dataset",
token=os.environ.get("HF_TOKEN"),
local_dir="/tmp/hf_prev",
)
h = hashlib.sha256(open(path, "rb").read()).hexdigest()
print(h)
sys.exit(0)
except Exception as e:
print(f"download failed: {e}", file=sys.stderr)
sys.exit(1)
PY
then
PREV_HASH=$(python - <<'PY'
import sys
try:
from huggingface_hub import hf_hub_download
import os, hashlib
path = hf_hub_download(
repo_id="automatelab/n8n-nodes-catalog",
filename="nodes.json",
repo_type="dataset",
token=os.environ.get("HF_TOKEN"),
local_dir="/tmp/hf_prev2",
)
print(hashlib.sha256(open(path,"rb").read()).hexdigest())
except:
print("none")
PY
)
echo "prev_hash=$PREV_HASH" >> "$GITHUB_OUTPUT"
if [ "$NEW_HASH" = "$PREV_HASH" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "prev_hash=none" >> "$GITHUB_OUTPUT"
fi
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
- name: Update dataset card Last Updated timestamp
if: steps.diff.outputs.changed == 'true'
run: |
MONTH=$(date -u +%Y-%m)
sed -i "s/Last updated: [0-9][0-9][0-9][0-9]-[0-9][0-9]\./Last updated: $MONTH./" dataset-card.md
echo "Updated dataset-card.md timestamp to $MONTH"
- name: Upload to HuggingFace
if: steps.diff.outputs.changed == 'true'
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
python - <<'PY'
import os
from huggingface_hub import HfApi
api = HfApi(token=os.environ["HF_TOKEN"])
repo_id = "automatelab/n8n-nodes-catalog"
uploads = [
("nodes.json", "nodes.json"),
("nodes.parquet", "nodes.parquet"),
("dataset-card.md", "README.md"),
]
for src, dst in uploads:
api.upload_file(
path_or_fileobj=src,
path_in_repo=dst,
repo_id=repo_id,
repo_type="dataset",
commit_message=f"monthly update: {dst}",
)
print(f"uploaded: {src} -> {dst}")
print("done")
PY
- name: No changes — skip upload
if: steps.diff.outputs.changed == 'false'
run: |
echo "nodes.json hash unchanged vs HuggingFace — skipping upload."
echo "prev=${{ steps.diff.outputs.prev_hash }}"
echo "new=${{ steps.diff.outputs.new_hash }}"
- name: Send failure email
if: failure()
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ secrets.SMTP_HOST }}
server_port: ${{ secrets.SMTP_PORT }}
username: ${{ secrets.SMTP_USER }}
password: ${{ secrets.SMTP_PASS }}
subject: "[n8n-nodes-catalog] monthly update FAILED — ${{ github.run_id }}"
to: ${{ secrets.SMTP_USER }}
from: ${{ secrets.SMTP_USER }}
body: |
The monthly n8n nodes catalog update workflow failed.
Workflow run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
Triggered by: ${{ github.event_name }}
Ref: ${{ github.ref }}
Check the run log above for the exact error. Common causes:
- HF_TOKEN secret missing or expired
- extraction script error (upstream n8n repo changed layout)
- HuggingFace API error
Fix and re-trigger manually via workflow_dispatch or wait for next month.