Add Figshare API authentication and rate limiting to fix 403 errors #56
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: | |
| force_refresh: | |
| description: 'Force refresh data (ignore cache)' | |
| required: false | |
| default: 'false' | |
| type: choice | |
| options: | |
| - 'true' | |
| - 'false' | |
| schedule: | |
| - cron: "30 2 * * 2" | |
| 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 | |
| uses: actions/cache@v3 | |
| with: | |
| path: ./output | |
| key: cache-files | |
| - name: Create output directory if it doesn't exist | |
| run: mkdir -p 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 exporter | |
| env: | |
| FIGSHARE_TOKEN: ${{ secrets.FIGSHARE_TOKEN }} | |
| run: | | |
| set -e | |
| cd ./output | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.force_refresh }}" = "true" ]; then | |
| echo "Running with --force-refresh (manually triggered)" | |
| python ../figshare.py --force-refresh | |
| else | |
| echo "Running with cache (default behavior)" | |
| python ../figshare.py | |
| fi | |
| - 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 |