10 if: ${{ !endsWith(github.repository, '/styles') }}
11 runs-on: ubuntu-latest
13 RSPM: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"
14 GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
20 uses: actions/setup-ruby@v1
25 uses: actions/setup-python@v2
29 - name: Install GitHub Pages, Bundler, and kramdown gems
31 gem install github-pages bundler kramdown
33 - name: Install Python modules
35 python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests
37 - name: Checkout the lesson
38 uses: actions/checkout@master
41 ref: ${{ github.event.pull_request.head.sha }}
43 - name: Look for R-markdown files
46 echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})"
49 if: steps.check-rmd.outputs.count != 0
50 uses: r-lib/actions/setup-r@master
54 - name: Install needed packages
55 if: steps.check-rmd.outputs.count != 0
57 install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
60 - name: Query dependencies
61 if: steps.check-rmd.outputs.count != 0
63 source('bin/dependencies.R')
64 deps <- identify_dependencies()
65 create_description(deps)
66 saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
67 writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
70 - name: Cache R packages
71 if: steps.check-rmd.outputs.count != 0
72 uses: actions/cache@v1
74 path: ${{ env.R_LIBS_USER }}
75 key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
76 restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
78 - name: Install system dependencies for R packages
79 if: steps.check-rmd.outputs.count != 0
84 done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
86 - name: Render the markdown and confirm that the site can be built
89 - name: Checkout github pages
90 if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
91 uses: actions/checkout@master
96 - name: Commit and Push
97 if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
99 # copy everything into gh-pages site
100 cp -r `ls -A | grep -v 'gh-pages' | grep -v '.git' | grep -v '.bundle/' | grep -v '_site'` gh-pages
101 # move into gh-pages, add, commit, and push
104 git config --local user.email "actions@github.com"
105 git config --local user.name "GitHub Actions"
107 git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }}"
108 git push origin gh-pages
112 - run: make lesson-check-all