|
| 1 | +name: Build website |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: gh-pages |
| 5 | + pull_request: [] |
| 6 | +jobs: |
| 7 | + build-website: |
| 8 | + if: github.repository != 'carpentries/styles' |
| 9 | + runs-on: ubuntu-latest |
| 10 | + defaults: |
| 11 | + run: |
| 12 | + shell: bash |
| 13 | + steps: |
| 14 | + - name: Set up Ruby |
| 15 | + uses: actions/setup-ruby@main |
| 16 | + with: |
| 17 | + ruby-version: '2.7.1' |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v2 |
| 21 | + with: |
| 22 | + python-version: '3.x' |
| 23 | + |
| 24 | + - name: Install GitHub Pages, Bundler, and kramdown gems |
| 25 | + run: | |
| 26 | + gem install github-pages bundler kramdown |
| 27 | +
|
| 28 | + - name: Install Python modules |
| 29 | + run: | |
| 30 | + python3 -m pip install --upgrade pip setuptools wheel pyyaml==5.3.1 requests |
| 31 | +
|
| 32 | + - name: Checkout the lesson |
| 33 | + uses: actions/checkout@master |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + ref: ${{ github.event.pull_request.head.sha }} |
| 37 | + |
| 38 | + - name: Look for R-markdown files |
| 39 | + id: check-rmd |
| 40 | + working-directory: lesson |
| 41 | + run: | |
| 42 | + echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})" |
| 43 | +
|
| 44 | + - name: Set up R |
| 45 | + if: steps.check-rmd.outputs.count != 0 |
| 46 | + uses: r-lib/actions/setup-r@master |
| 47 | + with: |
| 48 | + r-version: 'release' |
| 49 | + |
| 50 | + - name: Install needed packages |
| 51 | + if: steps.check-rmd.outputs.count != 0 |
| 52 | + run: | |
| 53 | + install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr')) |
| 54 | + shell: Rscript {0} |
| 55 | + |
| 56 | + - name: Query dependencies |
| 57 | + if: steps.check-rmd.outputs.count != 0 |
| 58 | + working-directory: lesson |
| 59 | + run: | |
| 60 | + source('bin/dependencies.R') |
| 61 | + deps <- identify_dependencies() |
| 62 | + create_description(deps) |
| 63 | + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) |
| 64 | + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") |
| 65 | + shell: Rscript {0} |
| 66 | + |
| 67 | + - name: Cache R packages |
| 68 | + if: steps.check-rmd.outputs.count != 0 |
| 69 | + uses: actions/cache@v1 |
| 70 | + with: |
| 71 | + path: ${{ env.R_LIBS_USER }} |
| 72 | + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} |
| 73 | + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- |
| 74 | + |
| 75 | + - name: Install system dependencies for R packages |
| 76 | + if: steps.check-rmd.outputs.count != 0 |
| 77 | + working-directory: lesson |
| 78 | + run: | |
| 79 | + while read -r cmd |
| 80 | + do |
| 81 | + eval sudo $cmd |
| 82 | + done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")') |
| 83 | +
|
| 84 | + - run: make site |
| 85 | + - run: make lesson-check |
| 86 | + if: always() |
| 87 | + - run: make lesson-check-all |
| 88 | + if: always() |
0 commit comments