Skip to content

Book have moved to external (#307) #64

Book have moved to external (#307)

Book have moved to external (#307) #64

on:
# run for PR with modify staging.
pull_request:
branches:
- master
- main
paths:
- R/staging.txt
# run when PR with staging.txt is merged
push:
branches:
- master
- main
paths:
- R/staging.txt
name: Update staging infos
jobs:
create_md:
name: fetch updated info
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RENV_PATHS_ROOT: ~/.local/share/renv
steps:
- name: Clone fork repository
uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
id: install-r
with:
r-version: '4.1.1'
use-public-rspm: true
- name: Cache Renv packages
uses: actions/cache@v4
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-1-${{ hashFiles('R/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-1-
${{ runner.os }}-renv-
- name: Install packages
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::restore(repos = "https://packagemanager.rstudio.com/all/latest")
shell: Rscript {0}
working-directory: R/
# create-md.R only creates the file for staging.txt url
- name: Update books
env:
RSC_BOOKDOWN_ORG_TOKEN: ${{ secrets.RSC_BOOKDOWN_ORG_TOKEN }}
PINS_VERBOSE: true
run: Rscript create-md.R
working-directory: R/
- name: move to external.txt
if: ${{ github.event_name == 'push' }}
run: |
cat staging.txt >> external.txt
cat /dev/null > staging.txt
working-directory: R/
- name: Show diff
run: |
git add content/\* R/\*
git diff --cached --color
- name: Commit changes to main branch to trigger a rebuild
if: ${{ github.event_name == 'push' }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git commit -m 'unstage new book and rebuild'
git push