Skip to content

Add files via upload #4

Add files via upload

Add files via upload #4

name: Sync Zenodo DOIs
on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
jobs:
sync-zenodo:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Fetch and write Zenodo DOIs
run: |
curl -s "https://zenodo.org/api/records?q=cabri%C3%A9&size=200&sort=mostrecent" \
-H "Accept: application/json" \
> zenodo_response.json
python3 -c "
import json

Check failure on line 24 in .github/workflows/sync-zenodo-v2.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/sync-zenodo-v2.yml

Invalid workflow file

You have an error in your yaml syntax on line 24
from datetime import datetime
with open('zenodo_response.json') as f:
data = json.load(f)
hits = data.get('hits', {}).get('hits', [])
total = data.get('hits', {}).get('total', 0)
lines = ['# BCT Programme - Zenodo DOI Registry', '', 'Auto-updated: ' + datetime.utcnow().strftime('%Y-%m-%d %H:%M UTC'), '', 'Total records: ' + str(total), '', '| DOI | Title | Date |', '|-----|-------|------|']
for hit in hits:
doi = hit.get('doi', 'N/A')
title = hit.get('metadata', {}).get('title', 'Untitled').replace('|', '-')[:80]
date = hit.get('metadata', {}).get('publication_date', '')
lines.append('| [' + doi + '](https://doi.org/' + doi + ') | ' + title + ' | ' + date + ' |')
with open('ZENODO_DOIS.md', 'w') as f:
f.write('\n'.join(lines))
print('Written ' + str(len(hits)) + ' records')
"
- name: Commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add ZENODO_DOIS.md
git diff --staged --quiet || git commit -m "Auto-sync Zenodo DOIs"
git push