pin ubuntu version to 20.04 (#540)
[rnaseq-cwl-training.git] / .github / workflows / website.yml
index f58e9c804ea11a4f9b69b2705a5b4e23f70bb2ff..b67e07ecc6f862331a70c28df4943732dbc5de8a 100644 (file)
@@ -1,15 +1,17 @@
 name: Website
 on:
   push:
-    branches: gh-pages
+    branches:
+      - gh-pages
+      - main
   pull_request: []
 jobs:
   build-website:
     if: ${{ !endsWith(github.repository, '/styles') }}
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     env:
-      RSPM: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"
-      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 
+      RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
+      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
     defaults:
       run:
         shell: bash
@@ -79,10 +81,33 @@ jobs:
           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()