Files
AMR/.github/workflows/website.yaml
T

103 lines
4.7 KiB
YAML

# ==================================================================== #
# TITLE: #
# AMR: An R Package for Working with Antimicrobial Resistance Data #
# #
# SOURCE CODE: #
# https://github.com/msberends/AMR #
# #
# PLEASE CITE THIS SOFTWARE AS: #
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
# Journal of Statistical Software, 104(3), 1-31. #
# https://doi.org/10.18637/jss.v104.i03 #
# #
# Developed at the University of Groningen and the University Medical #
# Center Groningen in the Netherlands, in collaboration with many #
# colleagues from around the world, see our website. #
# #
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# We created this package for both routine data analysis and academic #
# research and it was publicly released in the hope that it will be #
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
# #
# Visit our website for the full manual and a complete tutorial about #
# how to conduct AMR data analysis: https://amr-for-r.org #
# ==================================================================== #
# Create a website from the R documentation using pkgdown
# Git commit and push to the 'gh-pages' branch, keeping the folder 'release' that website-release.yaml maintains
on:
push:
# only on main
branches: 'main'
name: Update website
# website.yaml and website-release.yaml both push to the 'gh-pages' branch, so they must never run at the same time
concurrency:
group: gh-pages
cancel-in-progress: false
jobs:
update-website:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
# this is to keep timestamps, the default fetch-depth: 1 gets the timestamps of the moment of cloning
# we need this for the download page on our website - dates must be of the files, not of the latest git push
fetch-depth: 0
- name: restore timestamps
uses: chetan/git-restore-mtime-action@v2
- uses: r-lib/actions/setup-pandoc@v2
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
r-version: "release"
# use RStudio Package Manager (RSPM) to quickly install packages
use-public-rspm: true
- name: Set up R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
# add extra packages for website articles:
extra-packages: |
any::pkgdown
any::tidymodels
- name: Remove Welcome to AMR vignette
run: |
rm vignettes/welcome_to_AMR.Rmd
- name: Build website
run: |
Rscript -e 'pkgdown::build_site_github_pages(dest_dir = "docs", clean = TRUE, install = TRUE, new_process = FALSE)'
# Send updates to repo using GH Actions bot
# pkgdown::deploy_to_branch() would delete everything on 'gh-pages' that this build did not create, including the
# folder 'release' with the reference per released version, so the build is copied over 'gh-pages' without that folder
- name: Deploy website to gh-pages branch, keeping the folder 'release'
run: |
git config user.name "github-actions"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin gh-pages
git worktree add --detach "$RUNNER_TEMP/gh-pages" origin/gh-pages
rsync -a --delete --exclude '/.git' --exclude '/release/' docs/ "$RUNNER_TEMP/gh-pages/"
cd "$RUNNER_TEMP/gh-pages"
git add --all
if git diff --cached --quiet; then
echo "No changes to the website"
else
git commit -m "Built site for AMR@$(grep '^Version:' "$GITHUB_WORKSPACE/DESCRIPTION" | cut -d ' ' -f 2): ${GITHUB_SHA::7}"
git push origin HEAD:gh-pages
fi