-
-
Notifications
You must be signed in to change notification settings - Fork 3
65 lines (65 loc) · 3.98 KB
/
register-dois.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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 }}