Register DOIs for new Posts #8444
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: Register DOIs for new Posts | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "*/10 * * * *" | |
jobs: | |
register: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ">=1.23" | |
- name: Download most recent unregistered post | |
run: | | |
mkdir -p upload | |
curl https://api.rogue-scholar.org/posts/unregistered?per_page=10 > upload/posts.json | |
- name: Set number of unregistered posts as variable | |
id: current_number | |
run: | | |
echo "NUMBER=$(jq '."total-results"' upload/posts.json)" >> $GITHUB_OUTPUT | |
- name: Install commonmeta | |
if: ${{ fromJSON(steps.current_number.outputs.NUMBER) > 0 }} | |
run: | | |
go install github.com/front-matter/[email protected] | |
commonmeta -v | |
- name: Set current date as variable | |
if: ${{ fromJSON(steps.current_number.outputs.NUMBER) > 0 }} | |
run: | | |
echo "NOW=$(date +'%s')" >> $GITHUB_OUTPUT | |
id: current_date | |
- name: Convert posts to commonmeta and autogenerate dois based on prefix | |
if: ${{ fromJSON(steps.current_number.outputs.NUMBER) > 0 }} | |
run: | | |
commonmeta list upload/posts.json -f jsonfeed > upload/commonmeta.json | |
- name: Register Crossref DOIs | |
if: ${{ fromJSON(steps.current_number.outputs.NUMBER) > 0 }} | |
run: | | |
commonmeta push upload/commonmeta.json -f commonmeta -t crossrefxml --depositor "${{ secrets.CROSSREF_DEPOSITOR_NAME }}" --email "${{ secrets.CROSSREF_DEPOSITOR_EMAIL }}" --registrant "${{ secrets.CROSSREF_REGISTRANT }}" --login_id "${{ secrets.CROSSREF_USERNAME_WITH_ROLE }}" --login_passwd "${{ secrets.CROSSREF_PASSWORD }}" --legacyKey "${{ secrets.SUPABASE_KEY }}" > upload/response.json | |
cat upload/response.json | |
- name: create InvenioRDM content | |
if: ${{ fromJSON(steps.current_number.outputs.NUMBER) > 0 }} | |
run: | | |
commonmeta push upload/commonmeta.json -f commonmeta -t inveniordm --host rogue-scholar.org --token "${{ secrets.INVENIORDM_TOKEN }}" --legacyKey "${{ secrets.SUPABASE_KEY }}" > upload/response.json | |
cat upload/response.json | |
echo "UUID=$(jq -r '.[0].uuid' upload/response.json)" >> $GITHUB_OUTPUT | |
echo "DOI=$(jq -r '.[0].doi' upload/response.json)" >> $GITHUB_OUTPUT | |
echo "COMMUNITY=$(jq -r '.[0].community' upload/response.json)" >> $GITHUB_OUTPUT | |
id: response | |
- name: Update Front Matter blog | |
if: steps.response.outputs.COMMUNITY == 'front_matter' | |
run: commonmeta update-ghost-post --api-key ${{ secrets.GHOST_ADMIN_API_KEY }} --api-url ${{ secrets.GHOST_ADMIN_API_URL }} ${{ steps.response.outputs.UUID }} | |
- name: Update Upstream blog | |
if: steps.response.outputs.COMMUNITY == 'upstream' | |
run: commonmeta update-ghost-post --api-key ${{ secrets.UPSTREAM_ADMIN_API_KEY }} --api-url ${{ secrets.UPSTREAM_ADMIN_API_URL }} ${{ secrets.UPSTREAM_ADMIN_API_URL }} ${{ steps.response.outputs.UUID }} |