deploy-on-push-and-schedule #1793
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy-on-push-and-schedule | |
on: | |
push: | |
branches: ['main'] | |
schedule: | |
- cron: '0 17 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
env: | |
RSPM: 'https://packagemanager.rstudio.com/cran/__linux__/focal/latest' | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
if: "!contains(github.event.head_commit.message, 'ci-skip')" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
install-r: false | |
- name: Query dependencies | |
run: | | |
Rscript \ | |
-e "install.packages('remotes')" \ | |
-e "saveRDS(remotes::dev_package_deps(dependencies = TRUE), 'depends.Rds', version = 2)" | |
- name: Cache R packages | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-r-1-${{ hashFiles('depends.Rds') }} | |
restore-keys: ${{ runner.os }}-r-1- | |
- name: Install system dependencies | |
shell: Rscript {0} | |
env: | |
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc | |
run: | | |
remotes::install_github('carpentries/vise', dep = TRUE) | |
Sys.setenv("RSPM_ROOT" = "https://packagemanager.posit.co") | |
desc <- desc::description$new("${{ github.workspace }}/DESCRIPTION") | |
vise::ci_sysreqs(desc, execute = TRUE) | |
- name: Install dependencies | |
run: | | |
Rscript \ | |
-e "library(remotes)" \ | |
-e "update(remotes::dev_package_deps(dependencies = TRUE))" | |
- name: Run Script For Pre-workshop survey | |
run: | | |
Rscript \ | |
-e "source('archive-typeform.R')" \ | |
-e "cache_content(get_form('wi32rS'), 'pre-workshop')" | |
- name: Run Script for Post-workshop survey | |
run: | | |
Rscript \ | |
-e "source('archive-typeform.R')" \ | |
-e "cache_content(get_form('UgVdRQ'), 'post-workshop')" | |
- name: Run Script for Instructors Teaching Online survey | |
run: | | |
Rscript \ | |
-e "source('archive-typeform.R')" \ | |
-e "cache_content(get_form('aXXn4P'), 'instructor-teaching-online')" | |
- name: Run Script for Long-term survey | |
run: | | |
Rscript \ | |
-e "source('archive-typeform.R')" \ | |
-e "cache_content(get_form('cUoZrl'), 'long-term')" | |
- name: Run Script for Online Teaching Bonus Module Pre-Survey | |
run: | | |
Rscript \ | |
-e "source('archive-typeform.R')" \ | |
-e "cache_content(get_form('gnI2PnYT'), 'online-teaching-bonus-pre')" | |
- name: Run Script for Online Teaching Bonus Module Post-Survey | |
run: | | |
Rscript \ | |
-e "source('archive-typeform.R')" \ | |
-e "cache_content(get_form('rfYDXDrR'), 'online-teaching-bonus-post')" | |
- name: Run Script for Instructor Training Pre-Survey | |
run: | | |
Rscript \ | |
-e "source('archive-typeform.R')" \ | |
-e "cache_content(get_form('QVOarK'), 'instructor-training-pre')" | |
- name: Run Script for Instructor Training Post-Survey | |
run: | | |
Rscript \ | |
-e "source('archive-typeform.R')" \ | |
-e "cache_content(get_form('cjJ9UP'), 'instructor-training-post')" | |
- name: Commit files to main | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add * | |
git commit -m "[ci-skip] add latest version" || echo "Nothing to commit" | |
git push origin main || echo "No changes to push" | |
- name: Move files to public folder for deployment | |
run: | | |
Rscript \ | |
-e "source('build-website.R')" \ | |
-e "generate_archive_website()" | |
- name: Commit changes | |
if: github.ref == 'refs/heads/main' | |
run: | | |
cd public | |
git init --initial-branch=gh-pages | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
# adding the remote so git will recognise us because it thinks we are in a new repo | |
# https://zkamvar.netlify.app/blog/gh-drat/ | |
git remote add origin https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git | |
git add -A . | |
git commit -m '[ci-skip] Deploy to GitHub Pages' | |
git push --force origin HEAD:gh-pages # this will always push | |
- name: Ping Healthcheck when successful | |
if: ${{ success() }} | |
run: | | |
curl -fsS --retry 3 ${{ secrets.HEALTHCHECK_URL }} | |
- name: Ping Healthcheck when failure | |
if: ${{ failure() }} | |
run: | | |
curl -fsS --retry 3 ${{ secrets.HEALTHCHECK_URL }}/fail |