Skip to content

check-cran-status

check-cran-status #50

on:
workflow_dispatch:
schedule:
- cron: '0 6 * * 1,3,5' # Runs at 06:00 on Mon/Wed/Fri
name: check-cran-status
jobs:
fetch-deadlines:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
issues: write
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: |
gh
glue
- name: Check for existing CRAN issues
id: check-issues
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Count open issues with CRAN-related labels
ISSUE_COUNT=$(gh issue list --label "cran-deadline" --state open --json number | jq length)
if [ $ISSUE_COUNT -eq 0 ]; then
echo "should-run=true" >> $GITHUB_OUTPUT
echo "✅ Will run CRAN check"
else
echo "should-run=false" >> $GITHUB_OUTPUT
echo "⏭️ Skipping CRAN check - existing issues found"
fi
- name: Fetch deadline for this package
if: steps.check-issues.outputs.should-run == 'true'
shell: Rscript {0}
run: |
pkgname <- drop(read.dcf("DESCRIPTION", "Package"))
deadline <- subset(tools::CRAN_package_db(), Package == pkgname, "Deadline", drop=TRUE)
if (is.na(deadline)) {
quit()
}
gh::gh(
"POST /repos/{owner_repo}/issues",
owner_repo = Sys.getenv("GITHUB_REPOSITORY"),
title = paste("Fix CRAN R CMD check issues by", deadline),
body = glue::glue(
"This package is failing CRAN checks and is at risk of archival.",
"https://cran.r-project.org/web/checks/check_results_{pkgname}.html",
"This issue was opened by https://github.com/{Sys.getenv('GITHUB_REPOSITORY')}/actions/runs/{Sys.getenv('GITHUB_RUN_ID')}.",
.sep = "\n\n"
),
labels = list("cran-deadline")
)