figshare-cache #98
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: 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 */12 * * *" | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| 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: cache-files-${{ github.run_id }} | |
| restore-keys: | | |
| 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 '[email protected]' | |
| - 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 --use-author-cache | |
| else | |
| echo "Running figshare_fetch.py without cache (default behavior)" | |
| python ../figshare_fetch.py --rate-limit-delay 1 --max-retries 30 | |
| 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 | |
| - name: Save Cache from folder ./output | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: ./output | |
| key: ${{ steps.cache-restore-output.outputs.cache-primary-key || 'cache-files' }} | |
| - name: Generate publication statistics | |
| run: | | |
| cd ./output | |
| python ../generate_stats.py --all-csv figshare_articles_all.csv --dedup-csv figshare_articles.csv >> $GITHUB_STEP_SUMMARY | |
| - name: Nexus Repo Publish bibtex | |
| if: ${{ github.event_name != 'pull_request' }} | |
| uses: sonatype-nexus-community/nexus-repo-github-action@master | |
| with: | |
| serverUrl: https://lcas.lincoln.ac.uk/repository/ | |
| username: ${{ secrets.LCAS_REGISTRY_PUSHER }} | |
| password: ${{ secrets.LCAS_REGISTRY_TOKEN }} | |
| format: raw | |
| repository: misc | |
| coordinates: directory=bibtex | |
| assets: filename=lcas.bib | |
| filename: ./output/lcas.bib | |
| - name: Nexus Repo Publish figshare articles without duplicates CSV | |
| if: ${{ github.event_name != 'pull_request' }} | |
| uses: sonatype-nexus-community/nexus-repo-github-action@master | |
| with: | |
| serverUrl: https://lcas.lincoln.ac.uk/repository/ | |
| username: ${{ secrets.LCAS_REGISTRY_PUSHER }} | |
| password: ${{ secrets.LCAS_REGISTRY_TOKEN }} | |
| format: raw | |
| repository: misc | |
| coordinates: directory=bibtex | |
| assets: filename=figshare_articles.csv | |
| filename: ./output/figshare_articles.csv | |
| - name: Nexus Repo Publish all figshare articles CSV | |
| if: ${{ github.event_name != 'pull_request' }} | |
| uses: sonatype-nexus-community/nexus-repo-github-action@master | |
| with: | |
| serverUrl: https://lcas.lincoln.ac.uk/repository/ | |
| username: ${{ secrets.LCAS_REGISTRY_PUSHER }} | |
| password: ${{ secrets.LCAS_REGISTRY_TOKEN }} | |
| format: raw | |
| repository: misc | |
| coordinates: directory=bibtex | |
| assets: filename=figshare_articles_all.csv | |
| filename: ./output/figshare_articles_all.csv | |
| - name: Upload artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: outputs | |
| path: | | |
| ./output/*.csv | |
| ./output/*.bib | |
| retention-days: 30 |