Skip to content

Commit 09cc611

Browse files
Added workflow to update publications
1 parent 53ee3fa commit 09cc611

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Auto-Update Publications
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0' # Runs automatically every Sunday at midnight
6+
workflow_dispatch: # Allows manual triggering from the GitHub interface
7+
8+
jobs:
9+
update-data:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v3
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.x'
19+
20+
- name: Run Python Script
21+
run: python update_pubs.py
22+
23+
- name: Commit and Push changes
24+
run: |
25+
git config --global user.name 'github-actions[bot]'
26+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
27+
28+
git add _data/publications.json
29+
30+
# Generate the current date in YYYY-MM-DD format
31+
CURRENT_DATE=$(date +'%Y-%m-%d')
32+
33+
# Only commit if there are actual changes to prevent empty commits
34+
git diff --quiet && git diff --staged --quiet || git commit -m "Automated publication update from DBLP: $CURRENT_DATE"
35+
36+
git push

update_pubs.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import urllib.request
2+
import json
3+
import xml.etree.ElementTree as ET
4+
import re
5+
import os
6+
7+
def fetch_and_update_publications():
8+
url = 'https://dblp.org/pid/305/5359.xml'
9+
10+
try:
11+
# Fetch the XML from DBLP
12+
response = urllib.request.urlopen(url)
13+
tree = ET.parse(response)
14+
root = tree.getroot()
15+
except Exception as e:
16+
print(f"Error fetching or parsing XML: {e}")
17+
return
18+
19+
papers = []
20+
21+
# DBLP wraps each publication inside an <r> tag
22+
for r in root.findall('r'):
23+
for pub_type in ['article', 'inproceedings']:
24+
pub = r.find(pub_type)
25+
if pub is not None:
26+
27+
# 1. Extract and Clean Authors
28+
authors = []
29+
for author in pub.findall('author'):
30+
name = author.text
31+
# DBLP quirk: Remove trailing 4-digit disambiguation numbers (e.g., "Puneet Gupta 0002" -> "Puneet Gupta")
32+
clean_name = re.sub(r' \d{4}$', '', name)
33+
authors.append(clean_name)
34+
authors_str = ", ".join(authors)
35+
36+
# 2. Extract Title
37+
title_node = pub.find('title')
38+
title = title_node.text if title_node is not None else "Unknown Title"
39+
40+
# 3. Extract Year
41+
year_node = pub.find('year')
42+
year = year_node.text if year_node is not None else "Unknown Year"
43+
44+
# 4. Extract Venue (journal for articles, booktitle for conferences)
45+
venue_node = pub.find('journal') if pub.find('journal') is not None else pub.find('booktitle')
46+
venue_text = venue_node.text if venue_node is not None else "Unknown Venue"
47+
48+
# 5. Extract Link / DOI (<ee> tag)
49+
ee_node = pub.find('ee')
50+
ee = ee_node.text if ee_node is not None else ""
51+
52+
papers.append({
53+
"year": year,
54+
"authors": authors_str,
55+
"title": title,
56+
"venue": venue_text,
57+
"link": ee
58+
})
59+
60+
# Sort papers by year in descending order (Newest first)
61+
papers = sorted(papers, key=lambda x: str(x.get('year', '0')), reverse=True)
62+
63+
# Ensure the _data directory exists
64+
os.makedirs('_data', exist_ok=True)
65+
66+
# Save the cleaned data to Jekyll's _data folder
67+
output_path = os.path.join('_data', 'publications.json')
68+
with open(output_path, 'w', encoding='utf-8') as f:
69+
json.dump(papers, f, indent=4)
70+
71+
print(f"Successfully processed and sorted {len(papers)} publications from DBLP!")
72+
73+
if __name__ == "__main__":
74+
fetch_and_update_publications()

0 commit comments

Comments
 (0)