Harvest from Dimensions #95
This file contains 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: Harvest from Dimensions | |
on: | |
schedule: | |
- cron: '10 15 * * 1-5' | |
workflow_dispatch: | |
inputs: | |
reason: | |
description: 'Reason' | |
required: false | |
default: 'Manual trigger' | |
jobs: | |
get-dimensions: | |
runs-on: ubuntu-24.04 | |
outputs: | |
dois: ${{ steps.harvest.outputs.dois }} | |
message: ${{ steps.harvest.outputs.message }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Python Deps | |
shell: bash | |
run: pip install -r requirements.txt --break-system-packages | |
- name: Harvest DOIs | |
shell: bash | |
env: | |
DIMKEY: ${{ secrets.DIMKEY }} | |
id: harvest | |
run: python harvest.py dimensions -actor ${{github.actor}} -print >> $GITHUB_OUTPUT | |
prepare-dois: | |
name: Prepare Matrix Output of DOIs | |
needs: [get-dimensions] | |
runs-on: ubuntu-24.04 | |
outputs: | |
dois: ${{ steps.step1.outputs.matrix }} | |
env: | |
DOI: ${{ needs.get-dimensions.outputs.dois }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Process DOIs | |
shell: bash | |
run: python split_doi.py >> $GITHUB_OUTPUT | |
id: step1 | |
harvest: | |
runs-on: ubuntu-24.04 | |
needs: [prepare-dois,get-dimensions] | |
continue-on-error: true | |
strategy: | |
fail-fast: false | |
matrix: | |
doi: ${{ fromJSON(needs.prepare-dois.outputs.dois) }} | |
outputs: | |
dois: ${{ steps.step1.outputs.matrix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Python Deps | |
shell: bash | |
run: pip install -r requirements.txt --break-system-packages | |
- name: Make downloads folder | |
shell: bash | |
run: mkdir $HOME/Downloads | |
- name: Install irdmtools | |
shell: bash | |
run: curl https://caltechlibrary.github.io/irdmtools/installer.sh | sh | |
- name: Path | |
shell: bash | |
run: cp $HOME/bin/doi2rdm $HOME/.local/bin/. | |
- name: Harvest DOIs | |
shell: bash | |
env: | |
RDMTOK: ${{ secrets.RDMTOK }} | |
DIMKEY: ${{ secrets.DIMKEY }} | |
id: harvest | |
run: python harvest.py doi -doi "${{matrix.doi}}" -message "${{needs.get-dimensions.outputs.message}}" >> $GITHUB_OUTPUT | |
- uses: cloudposse/github-action-matrix-outputs-write@main | |
id: out | |
with: | |
matrix-step-name: ${{ github.job }} | |
matrix-key: ${{ matrix.doi }} | |
outputs: |- | |
doi: ${{ steps.harvest.outputs.doi }} | |
error: ${{steps.harvest.outputs.error }} | |
- name: System error on DOI | |
if: contains(steps.harvest.outputs.error, 'system') | |
run: | | |
echo ${{steps.harvest.outputs.error}} | |
false | |
- name: System intentionally skipped DOI | |
if: contains(steps.harvest.outputs.error, 'skipping') | |
run: | | |
echo ${{steps.harvest.outputs.error}} | |
false | |
- name: DOI not yet in Crossref or DataCite | |
if: contains(steps.harvest.outputs.error, 'not found') | |
run: | | |
echo ${{steps.harvest.outputs.error}} | |
false | |
write-output: | |
name: Write Output | |
runs-on: ubuntu-24.04 | |
needs: [harvest] | |
outputs: | |
result: "${{ steps.read.outputs.result }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: read | |
uses: cloudposse/github-action-matrix-outputs-read@main | |
id: read | |
with: | |
matrix-step-name: harvest | |
- name: write DOI | |
run: | | |
python save_dois.py '${{steps.read.outputs.result}}' | |
- name: Commit and Push Changes | |
id: commit-and-push | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: 'Update harvested DOIs' | |
file_pattern: 'harvested_dois.txt' | |
report-status: | |
name: Report Status | |
runs-on: ubuntu-24.04 | |
needs: [write-output] | |
outputs: | |
result: "${{ steps.read.outputs.result }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: read | |
uses: cloudposse/github-action-matrix-outputs-read@main | |
id: read | |
with: | |
matrix-step-name: harvest | |
- name: System error on DOI | |
run: | | |
python check_status.py '${{steps.read.outputs.result}}' |