authors update #3
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: cffconvert | |
on: | |
workflow_call: | |
push: | |
branches: | |
- "main" | |
paths: | |
- "CITATION.cff" | |
jobs: | |
validate: | |
name: cffconvert validate and update .zenodo.json | |
runs-on: ubuntu-22.04 | |
outputs: | |
pushed: ${{ steps.commit.outputs.pushed }} | |
steps: | |
- name: Check out a copy of the repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Check whether the citation metadata from CITATION.cff is valid | |
uses: citation-file-format/[email protected] | |
with: | |
args: "--validate" | |
- name: Convert CITATION.cff to Zenodo metadata format | |
uses: citation-file-format/[email protected] | |
with: | |
args: "--infile ./CITATION.cff --format zenodo --outfile .zenodo.json" | |
- name: Add Zenodo upload type | |
uses: sergeysova/jq-action@v2 | |
with: | |
cmd: jq '.upload_type += "lesson"' .zenodo.json > .zenodo.json.tmp && mv .zenodo.json.tmp .zenodo.json | |
- name: Fix Zenodo license field in the .zenodo.json metadata, as per new requirements | |
uses: sergeysova/jq-action@v2 | |
with: | |
cmd: jq '.license = .license.id' .zenodo.json > .zenodo.json.tmp && mv .zenodo.json.tmp .zenodo.json | |
- name: Enrich Zenodo metadata | |
uses: sergeysova/jq-action@v2 | |
with: | |
cmd: jq -s '.[0] * .[1]' .zenodo.json .github/templates/zenodo_metadata_enrichment.json > .zenodo.json.tmp && mv .zenodo.json.tmp .zenodo.json | |
- name: Check for changes | |
run: | | |
test -z "$(git status --porcelain)" || echo "changes=true" >> $GITHUB_ENV | |
- name: Commit and push Zenodo metadata | |
if: env.changes == 'true' | |
id: commit | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add .zenodo.json | |
git commit -m "Automated update of Zenodo metadata" || true | |
git push | |
echo "pushed=true" >> "$GITHUB_OUTPUT" | |
reconcile_mkdocs: | |
needs: validate | |
if: ${{ (needs.validate.outputs.pushed == 'true') && (github.event_name == 'push') }} | |
uses: ./.github/workflows/release-update-mkdocs-citation.yml | |
publish: | |
needs: reconcile_mkdocs | |
uses: ./.github/workflows/commit-publish-docs.yml |