-name: Build website
+name: Website
on:
push:
- branches: gh-pages
+ branches:
+ - gh-pages
+ - main
pull_request: []
jobs:
build-website:
- if: github.repository != 'carpentries/styles' && (github.repository_owner == 'swcarpentry' || github.repository_owner == 'datacarpentry' || github.repository_owner == 'librarycarpentry' || github.repository_owner == 'carpentries')
- runs-on: ubuntu-latest
+ if: ${{ !endsWith(github.repository, '/styles') }}
+ runs-on: ubuntu-20.04
+ env:
+ RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
+ GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
defaults:
run:
shell: bash
steps:
- name: Set up Ruby
- uses: actions/setup-ruby@main
+ uses: actions/setup-ruby@v1
with:
- ruby-version: '2.7.1'
+ ruby-version: '2.7'
- name: Set up Python
uses: actions/setup-python@v2
- name: Look for R-markdown files
id: check-rmd
- working-directory: lesson
run: |
echo "::set-output name=count::$(shopt -s nullglob; files=($(find . -iname '*.Rmd')); echo ${#files[@]})"
- name: Query dependencies
if: steps.check-rmd.outputs.count != 0
- working-directory: lesson
run: |
source('bin/dependencies.R')
deps <- identify_dependencies()
- name: Install system dependencies for R packages
if: steps.check-rmd.outputs.count != 0
- working-directory: lesson
run: |
while read -r cmd
do
eval sudo $cmd
- done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
+ done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")')
+
+ - name: Render the markdown and confirm that the site can be built
+ run: make site
+
+ - name: Checkout github pages
+ if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
+ uses: actions/checkout@master
+ with:
+ ref: gh-pages
+ path: gh-pages
+
+ - name: Commit and Push
+ if: ${{ github.event_name == 'push' && steps.check-rmd.outputs.count != 0 && github.ref != 'refs/heads/gh-pages'}}
+ run: |
+ # copy everything into gh-pages site
+ cp -r `ls -A | grep -v 'gh-pages' | grep -v '.git' | grep -v '.bundle/' | grep -v '_site'` gh-pages
+ # move into gh-pages, add, commit, and push
+ cd gh-pages
+ # setup git
+ git config --local user.email "actions@github.com"
+ git config --local user.name "GitHub Actions"
+ git add -A .
+ git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }}"
+ git push origin gh-pages
+ # return
+ cd ..
- - run: make site
- - run: make lesson-check
- if: always()
- run: make lesson-check-all
if: always()