Add steps to check out default.nix files #607
This file contains hidden or 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
# Create inst/default.nix | |
on: | |
push: | |
branches: [main, master] | |
name: create_inst_default.nix | |
permissions: write-all | |
jobs: | |
create-default-nix: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ github.token }} | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create this folder to silence warning | |
run: mkdir -p ~/.nix-defexpr/channels | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@main | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: rstats-on-nix | |
- name: Get latest commit hash | |
id: get_latest_commit | |
run: echo "LATEST_COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
- name: Generate .inst/extdata/default.nix | |
run: | | |
nix-shell --quiet -p R rPackages.{codetools,curl,jsonlite,sys,devtools} --run "Rscript -e \"devtools::load_all(); \ | |
rix(date = '2025-04-29', \ | |
git_pkgs = list(list(package_name = 'rix', repo_url = 'https://github.com/ropensci/rix/', commit = '${{ env.LATEST_COMMIT_HASH }}'), \ | |
list(package_name = 'rixpress', repo_url = 'https://github.com/b-rodrigues/rixpress/', commit = '93cda39228e5539530e4dea61f3092e32b426f54')), \ | |
ide = 'none', project_path = 'inst/extdata', overwrite = TRUE)\"" | |
- name: Check if PR exists | |
id: check_pr | |
run: | | |
PR=$(gh pr list -S 'Update default.nix' --json number --jq '.[0].number') | |
echo "PR_NUMBER=$PR" >> $GITHUB_ENV | |
- name: Push changes to update_default.nix branch | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "CI Robot" | |
git add . | |
git commit -m "Updated inst/extdata/default.nix" | |
git push origin main:update_default.nix --force | |
- name: Create Pull Request | |
if: env.PR_NUMBER == '' | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
branch: update_default.nix | |
title: 'Update default.nix' | |
body: 'Automated PR to update default.nix' | |
base: main | |
branch-suffix: '' |