diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml new file mode 100644 index 0000000..4d793ce --- /dev/null +++ b/.github/workflows/update-readme.yml @@ -0,0 +1,44 @@ +name: Generate README.md + +on: + pull_request: + paths: + - "markdown/README.md" + - "markdown/references.bib" + - "markdown/apa.csl" + - "update-readme.sh" + - ".github/workflows/update-readme.yml" + push: + branches: ["main"] + paths: + - "markdown/README.md" + - "markdown/references.bib" + - "markdown/apa.csl" + - "update-readme.sh" + - ".github/workflows/update-readme.yml" + +permissions: + contents: read + +jobs: + generate-readme: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Pandoc + uses: pandoc/actions/setup@v1 + with: + version: "3.1.13" + + - name: Run README update script + run: bash update-readme.sh + + - name: Check if README.md is up to date + run: | + if ! git diff --exit-code -- README.md; then + echo "README.md is out of date. Run update-readme.sh and re-commit the result." + git --no-pager diff -- README.md + exit 1 + fi diff --git a/markdown/README.md b/markdown/README.md index 8d565f3..c6d5923 100644 --- a/markdown/README.md +++ b/markdown/README.md @@ -13,6 +13,8 @@ https://github.com/MantisFEM/Research.git`, or to check out a single publication branch `name/of/publication` you can run `git clone --single-branch --branch=name/of/publication https://github.com/MantisFEM/Research.git`. +Testing workflow. + # Publications ## Papers diff --git a/update_readme.sh b/update_readme.sh new file mode 100755 index 0000000..20bb24c --- /dev/null +++ b/update_readme.sh @@ -0,0 +1,20 @@ +#! /usr/bin/env bash + +# This script will update 'README.md' from 'markdown/README.md'. + +# Check if 'pandoc' is installed and in 'PATH'. +if ! command -v pandoc >/dev/null 2>&1; then + echo "'pandoc' not found in 'PATH'. Please install or add to 'PATH'." + exit 1 +fi + +# Update README +pandoc markdown/README.md \ + --from markdown+citations \ + --to gfm \ + --citeproc \ + --wrap=none \ + --csl=markdown/apa.csl \ + --bibliography=markdown/references.bib \ + --metadata=reference-section-title:References \ + -o README.md