Skip to content

uoa11-figshare-cache #56

uoa11-figshare-cache

uoa11-figshare-cache #56

name: uoa11-figshare-cache
on:
workflow_dispatch:
inputs:
use_author_cache:
description: 'Use cached author data (instead of refreshing)'
required: false
default: 'false'
type: choice
options:
- 'true'
- 'false'
schedule:
- cron: "30 0 * * 0"
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: uoa11-figshare-processing-${{ github.ref }}
cancel-in-progress: true
jobs:
update-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Use Cache in folder ./output
id: cache-restore-output
uses: actions/cache/restore@v5
with:
path: ./output
key: uoa11-cache-files-${{ github.run_id }}
restore-keys: |
uoa11-cache-files-
- name: Create output directory if it doesn't exist
run: |
mkdir -p output
find ./output
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: |
git config --global user.name 'L-CAS GitHub'
git config --global user.email 'marc@hanheide.net'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
set -e
python -m pip install --upgrade pip
pip install -r requirements-frozen.txt
- name: Run figshare fetch (Step 1 - Retrieve articles and create CSV)
env:
FIGSHARE_TOKEN: ${{ secrets.FIGSHARE_TOKEN }}
run: |
set -e
cd ./output
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.use_author_cache }}" = "true" ]; then
echo "Running figshare_fetch.py with --use-author-cache (manually triggered)"
python ../figshare_fetch.py -c ../uoa11-authors.yaml --use-author-cache --max-retries 30 --rate-limit-delay 0.1 -o uoa11-figshare_articles.csv -O uoa11-figshare_articles_all.csv
else
echo "Running figshare_fetch.py without cache (default behavior)"
python ../figshare_fetch.py -c ../uoa11-authors.yaml --rate-limit-delay 0.1 --max-retries 30 -o uoa11-figshare_articles.csv -O uoa11-figshare_articles_all.csv
fi
- name: Run figshare bibtex (Step 2 - Generate bibtex from CSV)
run: |
set -e
cd ./output
echo "Running figshare_bibtex.py to generate bibtex from CSV"
python ../figshare_bibtex.py -i uoa11-figshare_articles.csv -o uoa11.bib
- name: Save Cache from folder ./output
if: always()
uses: actions/cache/save@v5
with:
path: ./output
key: ${{ steps.cache-restore-output.outputs.cache-primary-key || 'uoa11-cache-files' }}
- name: Generate publication statistics
run: |
cd ./output
python ../generate_stats.py --all-csv uoa11-figshare_articles_all.csv --dedup-csv uoa11-figshare_articles.csv >> $GITHUB_STEP_SUMMARY
- name: Publish outputs to Nexus via HTTP PUT
if: ${{ github.event_name != 'pull_request' }}
env:
NEXUS_USER: ${{ secrets.LCAS_REGISTRY_PUSHER }}
NEXUS_PASS: ${{ secrets.LCAS_REGISTRY_TOKEN }}
NEXUS_BASE_URL: https://lcas.lincoln.ac.uk/repository/repository/misc/bibtex/
run: |
set -euo pipefail
for file in uoa11.bib uoa11-figshare_articles.csv uoa11-figshare_articles_all.csv; do
local_path="./output/${file}"
target_url="${NEXUS_BASE_URL}/${file}"
if [ ! -f "$local_path" ]; then
echo "Expected file not found: $local_path"
exit 1
fi
echo "Uploading ${local_path} -> ${target_url}"
curl --fail --show-error --silent \
-u "${NEXUS_USER}:${NEXUS_PASS}" \
--upload-file "$local_path" \
"$target_url"
done
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: outputs
path: |
./output/*.csv
./output/*.bib
retention-days: 30