|
| 1 | +name: uoa11-figshare-cache |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + use_author_cache: |
| 7 | + description: 'Use cached author data (instead of refreshing)' |
| 8 | + required: false |
| 9 | + default: 'false' |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - 'true' |
| 13 | + - 'false' |
| 14 | + # schedule: |
| 15 | + # - cron: "30 */12 * * *" |
| 16 | + # push: |
| 17 | + # branches: |
| 18 | + # - main |
| 19 | + pull_request: |
| 20 | + branches: |
| 21 | + - main |
| 22 | + |
| 23 | +concurrency: |
| 24 | + group: uoa11-figshare-processing-${{ github.ref }} |
| 25 | + cancel-in-progress: true |
| 26 | + |
| 27 | +jobs: |
| 28 | + update-cache: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v3 |
| 32 | + with: |
| 33 | + fetch-depth: 1 |
| 34 | + |
| 35 | + - name: Use Cache in folder ./output |
| 36 | + id: cache-restore-output |
| 37 | + uses: actions/cache/restore@v5 |
| 38 | + with: |
| 39 | + path: ./output |
| 40 | + key: uoa11-cache-files-${{ github.run_id }} |
| 41 | + restore-keys: | |
| 42 | + uoa11-cache-files- |
| 43 | +
|
| 44 | + - name: Create output directory if it doesn't exist |
| 45 | + run: | |
| 46 | + mkdir -p output |
| 47 | + find ./output |
| 48 | +
|
| 49 | + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." |
| 50 | + |
| 51 | + - run: | |
| 52 | + git config --global user.name 'L-CAS GitHub' |
| 53 | + git config --global user.email 'marc@hanheide.net' |
| 54 | +
|
| 55 | + - name: Set up Python |
| 56 | + uses: actions/setup-python@v4 |
| 57 | + with: |
| 58 | + python-version: '3.10' |
| 59 | + |
| 60 | + - name: Install dependencies |
| 61 | + run: | |
| 62 | + set -e |
| 63 | + python -m pip install --upgrade pip |
| 64 | + pip install -r requirements-frozen.txt |
| 65 | + |
| 66 | + - name: Run figshare fetch (Step 1 - Retrieve articles and create CSV) |
| 67 | + env: |
| 68 | + FIGSHARE_TOKEN: ${{ secrets.FIGSHARE_TOKEN }} |
| 69 | + run: | |
| 70 | + set -e |
| 71 | + cd ./output |
| 72 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.use_author_cache }}" = "true" ]; then |
| 73 | + echo "Running figshare_fetch.py with --use-author-cache (manually triggered)" |
| 74 | + python ../figshare_fetch.py -f ../uoa11-authors.txt --use-author-cache --max-retries 30 --rate-limit-delay 0.1 -o uoa11-figshare_articles.csv -O uoa11-figshare_articles_all.csv |
| 75 | + else |
| 76 | + echo "Running figshare_fetch.py without cache (default behavior)" |
| 77 | + python ../figshare_fetch.py -f ../uoa11-authors.txt --rate-limit-delay 0.1 --max-retries 30 -o uoa11-figshare_articles.csv -O uoa11-figshare_articles_all.csv |
| 78 | + fi |
| 79 | + |
| 80 | + - name: Run figshare bibtex (Step 2 - Generate bibtex from CSV) |
| 81 | + run: | |
| 82 | + set -e |
| 83 | + cd ./output |
| 84 | + echo "Running figshare_bibtex.py to generate bibtex from CSV" |
| 85 | + python ../figshare_bibtex.py -i uoa11-figshare_articles.csv -o uoa11.bib |
| 86 | +
|
| 87 | + - name: Save Cache from folder ./output |
| 88 | + if: always() |
| 89 | + uses: actions/cache/save@v5 |
| 90 | + with: |
| 91 | + path: ./output |
| 92 | + key: ${{ steps.cache-restore-output.outputs.cache-primary-key || 'uoa11-cache-files' }} |
| 93 | + |
| 94 | + - name: Generate publication statistics |
| 95 | + run: | |
| 96 | + cd ./output |
| 97 | + python ../generate_stats.py --all-csv uoa11-figshare_articles_all.csv --dedup-csv uoa11-figshare_articles.csv >> $GITHUB_STEP_SUMMARY |
| 98 | +
|
| 99 | + - name: Nexus Repo Publish bibtex |
| 100 | + if: ${{ github.event_name != 'pull_request' }} |
| 101 | + uses: sonatype-nexus-community/nexus-repo-github-action@master |
| 102 | + with: |
| 103 | + serverUrl: https://lcas.lincoln.ac.uk/repository/ |
| 104 | + username: ${{ secrets.LCAS_REGISTRY_PUSHER }} |
| 105 | + password: ${{ secrets.LCAS_REGISTRY_TOKEN }} |
| 106 | + format: raw |
| 107 | + repository: misc |
| 108 | + coordinates: directory=bibtex |
| 109 | + assets: filename=uoa11.bib |
| 110 | + filename: ./output/uoa11.bib |
| 111 | + |
| 112 | + - name: Nexus Repo Publish figshare articles without duplicates CSV |
| 113 | + if: ${{ github.event_name != 'pull_request' }} |
| 114 | + uses: sonatype-nexus-community/nexus-repo-github-action@master |
| 115 | + with: |
| 116 | + serverUrl: https://lcas.lincoln.ac.uk/repository/ |
| 117 | + username: ${{ secrets.LCAS_REGISTRY_PUSHER }} |
| 118 | + password: ${{ secrets.LCAS_REGISTRY_TOKEN }} |
| 119 | + format: raw |
| 120 | + repository: misc |
| 121 | + coordinates: directory=bibtex |
| 122 | + assets: filename=uoa11-figshare_articles.csv |
| 123 | + filename: ./output/uoa11-figshare_articles.csv |
| 124 | + |
| 125 | + - name: Nexus Repo Publish all figshare articles CSV |
| 126 | + if: ${{ github.event_name != 'pull_request' }} |
| 127 | + uses: sonatype-nexus-community/nexus-repo-github-action@master |
| 128 | + with: |
| 129 | + serverUrl: https://lcas.lincoln.ac.uk/repository/ |
| 130 | + username: ${{ secrets.LCAS_REGISTRY_PUSHER }} |
| 131 | + password: ${{ secrets.LCAS_REGISTRY_TOKEN }} |
| 132 | + format: raw |
| 133 | + repository: misc |
| 134 | + coordinates: directory=bibtex |
| 135 | + assets: filename=uoa11-figshare_articles_all.csv |
| 136 | + filename: ./output/uoa11-figshare_articles_all.csv |
| 137 | + |
| 138 | + - name: Upload artifacts |
| 139 | + if: always() |
| 140 | + uses: actions/upload-artifact@v4 |
| 141 | + with: |
| 142 | + name: outputs |
| 143 | + path: | |
| 144 | + ./output/*.csv |
| 145 | + ./output/*.bib |
| 146 | + retention-days: 30 |
0 commit comments