Register DOIs for new Posts #56980
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.22' | |
- name: Download most recent unregistered post | |
run: | | |
mkdir -p upload | |
curl https://api.rogue-scholar.org/posts/unregistered?per_page=1 > 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 version | |
- 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: Convert posts to crossref xml | |
if: ${{ fromJSON(steps.current_number.outputs.NUMBER) > 0 }} | |
run: | | |
commonmeta list upload/commonmeta.json -f commonmeta --depositor "${{ secrets.CROSSREF_DEPOSITOR_NAME }}" --email "${{ secrets.CROSSREF_DEPOSITOR_EMAIL }}" --registrant "${{ secrets.CROSSREF_REGISTRANT }}" -t crossrefxml > upload/${{ steps.current_date.outputs.NOW }} | |
- name: Update content via Crossref API | |
if: ${{ fromJSON(steps.current_number.outputs.NUMBER) > 0 }} | |
run: | | |
curl -X POST https://doi.crossref.org/servlet/deposit -F "operation=doMDUpload" -F "login_id=${{ secrets.CROSSREF_USERNAME_WITH_ROLE }}" -F "login_passwd=${{ secrets.CROSSREF_PASSWORD }}" -F "fname=@upload/${{ steps.current_date.outputs.NOW }}" | |
- name: Set post uuid, doi and blog slug as variables | |
if: ${{ fromJSON(steps.current_number.outputs.NUMBER) > 0 }} | |
run: | | |
echo "UUID=$(jq -r '[.[] | .identifiers | .[1].identifier] | first' upload/commonmeta.json)" >> $GITHUB_OUTPUT | |
echo "DOI=$(jq -rc '[.[] | .id] | first' upload/commonmeta.json)" >> $GITHUB_OUTPUT | |
echo "SLUG=$(jq -r '[.[] | .container.identifier] | first' upload/commonmeta.json)" >> $GITHUB_OUTPUT | |
id: current_post | |
- name: update Rogue Scholar post | |
if: ${{ fromJSON(steps.current_number.outputs.NUMBER) > 0 }} | |
run: | | |
curl -X PATCH https://db.rogue-scholar.org/rest/v1/posts?id=eq.${{ steps.current_post.outputs.UUID }} -H "apikey: ${{ secrets.SUPABASE_KEY }}" -H "Authorization: Bearer ${{ secrets.SUPABASE_KEY }}" -H "Content-Type: application/json" -H "Prefer: return=minimal" -d '{ "doi": "${{ steps.current_post.outputs.DOI }}", "indexed_at": "${{ steps.current_date.outputs.NOW }}", "indexed": true }' | |
- name: Update Front Matter blog | |
if: steps.current_post.outputs.SLUG == '2749-9952' | |
run: commonmeta update-ghost-post --api-key ${{ secrets.GHOST_ADMIN_API_KEY }} --api-url ${{ secrets.GHOST_ADMIN_API_URL }} ${{ steps.current_post.outputs.UUID }} | |
- name: Update Upstream blog | |
if: steps.current_post.outputs.SLUG == 'https://rogue-scholar.org/blogs/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.current_post.outputs.UUID }} | |
- name: Update OA.Works blog | |
if: steps.current_post.outputs.SLUG == 'https://rogue-scholar.org/blogs/oa_works/' | |
run: commonmeta update-ghost-post --api-key ${{ secrets.OA_WORKS_ADMIN_API_KEY }} --api-url ${{ secrets.OA_WORKS_ADMIN_API_URL }} ${{ steps.current_post.outputs.UUID }} |