Skip to content

Commit

Permalink
added workflow for updating citation
Browse files Browse the repository at this point in the history
  • Loading branch information
bcallaway11 committed Jan 31, 2025
1 parent a9f59ab commit 6af0530
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/update-citation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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 "github-actions@github.com"
git add inst/CITATION CITATION.cff
git commit -m "Auto-update citation files" || echo "No changes to commit"
git push

0 comments on commit 6af0530

Please sign in to comment.