Add Zenodo.json for author tracking #5
Workflow file for this run
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: Validate Zenodo Metadata | |
on: | |
push: | |
paths: | |
- '.zenodo.json' | |
pull_request: | |
paths: | |
- '.zenodo.json' | |
jobs: | |
validate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
- name: Install Dependencies | |
run: install.packages("jsonvalidate") | |
shell: Rscript {0} | |
- name: Get JSON schema | |
run: | | |
curl -s -o schema.json \ | |
https://raw.githubusercontent.com/zenodo/zenodo/master/zenodo/modules/deposit/jsonschemas/deposits/records/legacyrecord.json | |
- name: Validate JSON | |
shell: Rscript {0} | |
run: | | |
library(jsonvalidate); | |
validate <- jsonvalidate::json_validator('schema.json') | |
z <- tryCatch(validate('.zenodo.json', | |
verbose = TRUE, | |
error = FALSE, | |
greedy = TRUE), | |
error = function(e) e | |
) | |
if(!z){ | |
errs <- attr(z, "errors", TRUE) | |
msg <- sprintf("'%s' %s", | |
errs$field, | |
errs$message) | |
cat(paste(msg, collapse = "\n")) | |
cat("\n") | |
stop("json validation failed", call. = FALSE) | |
} | |