@@ -36,41 +36,49 @@ jobs:
3636 run : python -m pip install --disable-pip-version-check requests beautifulsoup4 lxml
3737
3838 - name : Harvest and reconcile records
39- run : python scripts/fetch_jama_network_open.py
39+ id : harvest
40+ shell : bash
41+ run : |
42+ mkdir -p "$OUT_DIR"
43+ set +e
44+ python scripts/fetch_jama_network_open.py > "$OUT_DIR/run.log" 2>&1
45+ code=$?
46+ echo "exit_code=$code" >> "$GITHUB_OUTPUT"
47+ cat "$OUT_DIR/run.log"
48+ exit 0
4049
4150 - name : Write run metadata
51+ if : always()
4252 shell : bash
4353 run : |
4454 python - <<'PY'
4555 import json, os
4656 from pathlib import Path
4757 out = Path(os.environ['OUT_DIR'])
48- summary = json.loads((out / 'summary.json').read_text(encoding='utf-8'))
58+ summary_path = out / 'summary.json'
59+ summary = json.loads(summary_path.read_text(encoding='utf-8')) if summary_path.exists() else {}
4960 payload = {
5061 'run_id': int(os.environ['GITHUB_RUN_ID']),
5162 'run_attempt': int(os.environ['GITHUB_RUN_ATTEMPT']),
5263 'commit_sha': os.environ['GITHUB_SHA'],
5364 'artifact_name': 'jama-network-open-six-month-literature',
65+ 'harvest_exit_code': '${{ steps.harvest.outputs.exit_code }}',
5466 'summary': summary,
5567 }
5668 (out / 'latest_run.json').write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding='utf-8')
5769 PY
5870
5971 - name : Upload complete data artifact
72+ if : always()
6073 uses : actions/upload-artifact@v4
6174 with :
6275 name : jama-network-open-six-month-literature
63- path : |
64- jama_output/research_papers.csv
65- jama_output/all_records.csv
66- jama_output/summary.json
67- jama_output/preview_25.csv
68- jama_output/latest_run.json
76+ path : jama_output/**
6977 if-no-files-found : error
7078 retention-days : 7
7179
7280 - name : Publish run pointer and preview
73- if : github.event_name == 'push'
81+ if : github.event_name == 'push' && steps.harvest.outputs.exit_code == '0'
7482 shell : bash
7583 run : |
7684 git config user.name 'github-actions[bot]'
8088 git commit -m 'Update JAMA Network Open harvest summary'
8189 git push
8290 fi
91+
92+ - name : Fail workflow when harvest failed
93+ if : steps.harvest.outputs.exit_code != '0'
94+ run : exit 1
0 commit comments