Skip to content

Update Citation Files #2

Update Citation Files

Update Citation Files #2

name: Update Citation Files
on:
push:
paths:
- "DESCRIPTION"
workflow_dispatch:
jobs:
update-citation:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up R
uses: r-lib/actions/setup-r@v2
- name: Install dependencies
run: |
Rscript -e 'install.packages(c("usethis", "cffr", "desc"))'
- name: Update inst/CITATION
run: |
Rscript -e '
library(desc);
d <- desc::desc_get();
citation_text <- sprintf("citHeader(\"To cite this package, use:\")\n\nbibentry(\n bibtype = \"Manual\",\n title = \"%s\",\n author = %s,\n year = \"%s\",\n note = \"R package version %s\",\n url = \"%s\"\n)",
d["Title"], d["Authors@R"], format(Sys.Date(), "%Y"), d["Version"], d["URL"]);
writeLines(citation_text, "inst/CITATION")'
- name: Update CITATION.cff
run: |
Rscript -e 'cffr::cff_write()'
- name: Commit and Push if Changed
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add inst/CITATION CITATION.cff
git commit -m "Auto-update citation files" || echo "No changes to commit"
git push