update website and readme #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: 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); | |
# Read package metadata | |
package_title <- desc::desc_get("Title") | |
authors <- desc::desc_get("Authors@R") | |
version <- desc::desc_get("Version") | |
url <- desc::desc_get("URL") | |
year <- format(Sys.Date(), "%Y") # Get current year | |
# Generate citation content dynamically | |
citation_text <- sprintf("citHeader(\"To cite this package, use:\")\n\n | |
bibentry(\n | |
bibtype = \"Manual\",\n | |
title = \"%s\",\n | |
author = %s,\n | |
year = \"%s\",\n | |
note = \"R package version %s\",\n | |
url = \"%s\" | |
)", package_title, authors, year, version, url) | |
# Write the updated citation file | |
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 |