Add files via upload #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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 | ||