Skip to content

Find CRAN/incoming updates #1341

Find CRAN/incoming updates

Find CRAN/incoming updates #1341

Workflow file for this run

on:
schedule:
- cron: '*/60 * * * *'
workflow_dispatch:
name: Find CRAN/incoming updates
concurrency: ${{ github.workflow }}
permissions:
contents: write
actions: write
jobs:
updates:
runs-on: ubuntu-latest
name: Check for CRAN updates
container:
image: ghcr.io/r-hub/r-minimal/r-minimal:latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: 'updates'
- name: Find updates
timeout-minutes: 10
run: |
df <- as.data.frame(available.packages(repos = 'https://cloud.r-project.org'))
newpkgs <- paste(df$Package, df$Version)
oldpkgs <- readLines("cran.txt")
changes <- sub(" .*", "", setdiff(newpkgs, oldpkgs))
writeLines(changes, 'changes.txt')
writeLines(newpkgs, 'newcran.txt')
shell: Rscript {0}
- uses: actions/upload-artifact@v7
if: always()
with:
name: updates
path: |
changes.txt
newcran.txt
trigger:
runs-on: ubuntu-latest
needs: [updates]
name: Commit and trigger checks
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: 'updates'
- uses: actions/download-artifact@v8
with:
name: updates
path: '/tmp/updates'
- name: Commit new cran
shell: bash
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
cp -f /tmp/updates/newcran.txt cran.txt
git add cran.txt
git commit -m "Update CRAN" || exit 0
git push
- name: Trigger checks
run: |
while read package; do
echo "Triggering $package"
gh workflow run check.yml -f package=$package || true
sleep 60
done </tmp/updates/changes.txt
env:
GH_TOKEN: ${{ github.token }}
incoming:
runs-on: ubuntu-latest
name: Update incoming packages
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Process incoming changes
timeout-minutes: 5
shell: bash
run: |
set -euo pipefail
remote=$(curl -sSl --retry 3 --fail-with-body ftp://cran.r-project.org/incoming/special/linux-arm64/ | sort -u | sed 's/.tar.gz//g')
current=$(ls .incoming | grep -v README.md | sort -u || true)
echo "Checking files removed from incoming"
comm -23 <(printf '%s\n' "$current") <(printf '%s\n' "$remote") | tee -a /tmp/removed.txt
echo "Checking files added to incoming"
comm -13 <(printf '%s\n' "$current") <(printf '%s\n' "$remote") | tee -a /tmp/added.txt
while read -r pkgfile; do
if [ "$pkgfile" ]; then
echo "Starting check for $pkgfile"
gh workflow run incoming.yml -f "pkgfile=${pkgfile}.tar.gz" || true
sleep 10
fi
done < /tmp/added.txt
while read -r pkgfile; do
if [ "$pkgfile" ]; then
echo "Removing incoming result for $pkgfile"
rm -Rf ".incoming/$pkgfile"
git add ".incoming/$pkgfile"
fi
done < /tmp/removed.txt
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Cleanup incoming" || exit 0
git push
env:
GH_TOKEN: ${{ github.token }}