Skip to content

Commit 58f5504

Browse files
author
Sreeparna Deb
committed
workflow:add plugin info sync workflow (manual test push to ft/test-plugin-push)
1 parent e7cffe7 commit 58f5504

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Auto-update plugin card on website
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
update-card:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout this repo (plugin source)
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.10"
18+
19+
- name: Install Python dependencies
20+
run: pip install requests pyyaml
21+
22+
- name: Get repo name and run script
23+
run: |
24+
REPO_NAME=$(basename "${{ github.repository }}")
25+
echo "Running from repo: $REPO_NAME"
26+
python scripts/update_plugininfo.py "$REPO_NAME"
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Clone manivaultstudio.github.io (feature branch)
31+
run: |
32+
git clone --branch ft/test-plugin-push https://x-access-token:${{ secrets.GH_PAGES_DEPLOY_TOKEN }}@github.com/ManiVaultStudio/manivaultstudio.github.io.git target-repo
33+
REPO_NAME=$(basename "${{ github.repository }}")
34+
cp "$REPO_NAME.md" target-repo/_plugins/
35+
36+
- name: Commit and push
37+
run: |
38+
cd target-repo
39+
git config user.name "ManiVault Bot"
40+
git config user.email "bot@manivault.studio"
41+
git add _plugins/
42+
git commit -m "🔄 Auto-update plugin card from $REPO_NAME"
43+
git push origin ft/test-plugin-push

scripts/update_plugininfo.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import requests
2+
import os
3+
import sys
4+
import yaml
5+
from datetime import datetime
6+
7+
ORG = "ManiVaultStudio"
8+
REPO = sys.argv[1] if len(sys.argv) > 1 else "Scatterplot"
9+
OUTPUT_PATH = f"{REPO.lower()}.md"
10+
GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
11+
12+
HEADERS = {
13+
"Accept": "application/vnd.github+json",
14+
}
15+
if GITHUB_TOKEN:
16+
HEADERS["Authorization"] = f"Bearer {GITHUB_TOKEN}"
17+
18+
def fetch_plugin_info():
19+
url = f"https://raw.githubusercontent.com/{ORG}/{REPO}/master/PluginInfo.json"
20+
r = requests.get(url)
21+
r.raise_for_status()
22+
return r.json()
23+
24+
def fetch_contributors():
25+
url = f"https://api.github.com/repos/{ORG}/{REPO}/contributors"
26+
r = requests.get(url, headers=HEADERS)
27+
r.raise_for_status()
28+
return [user["login"] for user in r.json()]
29+
30+
def write_markdown(info, authors):
31+
metadata = {
32+
"layout": "plugin",
33+
"name": info["name"],
34+
"shortname": info["name"].split()[0],
35+
"key": REPO.lower(),
36+
"type": info.get("type", "").lower(),
37+
"version": info["version"]["plugin"],
38+
"date": datetime.today().strftime("%Y-%m-%d %H:%M:%S"),
39+
"organization": "ManiVault",
40+
"organization-link": "https://www.manivault.studio",
41+
"authors": authors,
42+
"shortdescription": f"{info['type']} plugin with dependencies: {', '.join(info.get('dependencies', []))}"
43+
}
44+
45+
with open(OUTPUT_PATH, "w") as f:
46+
f.write("---\n")
47+
yaml.dump(metadata, f, sort_keys=False)
48+
f.write("---\n")
49+
50+
print(f"✅ Updated {OUTPUT_PATH}")
51+
52+
if __name__ == "__main__":
53+
info = fetch_plugin_info()
54+
authors = fetch_contributors()
55+
write_markdown(info, authors)

0 commit comments

Comments
 (0)