GH Website action: rename + don't use lesson directory (#504)
[rnaseq-cwl-training.git] / .github / workflows / website.yml
1 name: Website
2 on:
3   push:
4     branches: gh-pages
5   pull_request: []
6 jobs:
7   build-website:
8     if: github.repository != 'carpentries/styles' && (github.repository_owner == 'swcarpentry' || github.repository_owner == 'datacarpentry' || github.repository_owner == 'librarycarpentry' || github.repository_owner == 'carpentries')
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         run: |
41           echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})"
42
43       - name: Set up R
44         if: steps.check-rmd.outputs.count != 0
45         uses: r-lib/actions/setup-r@master
46         with:
47           r-version: 'release'
48
49       - name: Install needed packages
50         if: steps.check-rmd.outputs.count != 0
51         run: |
52           install.packages(c('remotes', 'rprojroot', 'renv', 'desc', 'rmarkdown', 'knitr'))
53         shell: Rscript {0}
54
55       - name: Query dependencies
56         if: steps.check-rmd.outputs.count != 0
57         run: |
58           source('bin/dependencies.R')
59           deps <- identify_dependencies()
60           create_description(deps)
61           saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
62           writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
63         shell: Rscript {0}
64
65       - name: Cache R packages
66         if: steps.check-rmd.outputs.count != 0
67         uses: actions/cache@v1
68         with:
69           path: ${{ env.R_LIBS_USER }}
70           key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
71           restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
72
73       - name: Install system dependencies for R packages
74         if: steps.check-rmd.outputs.count != 0
75         run: |
76           while read -r cmd
77           do
78             eval sudo $cmd
79           done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
80
81       - run: make site
82       - run: make lesson-check
83         if: always()
84       - run: make lesson-check-all
85         if: always()