Build pkgdown site #159
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: Build pkgdown site | |
on: | |
workflow_dispatch: # Trigger manually | |
workflow_run: | |
workflows: ["Trigger Build pkgdown Site"] | |
types: | |
- completed | |
concurrency: | |
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} # Use the event name, branch reference, and workflow name as the concurrency group | |
cancel-in-progress: true # Cancel any in-progress runs in the same group | |
jobs: | |
build-site: | |
runs-on: ${{ matrix.config.os }} | |
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- {os: ubuntu-latest, r: 'release'} | |
env: | |
RSPM: ${{ matrix.config.rspm }} | |
GITHUB_PAT: ${{ secrets.GH_PAT }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Debug concurrency group | |
run: | | |
echo "Concurrency group:" | |
echo "${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}" | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.config.r }} | |
http-user-agent: ${{ matrix.config.http-user-agent }} | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libxml2-dev libssl-dev libcurl4-openssl-dev | |
sudo apt-get install -y libharfbuzz-dev libfribidi-dev | |
sudo apt-get install -y pandoc | |
sudo apt-get install -y libudunits2-dev | |
sudo apt-get install -y libgeos-dev libproj-dev libgdal-dev | |
- name: Install R package dependencies | |
run: | | |
install.packages('remotes') | |
remotes::install_deps(dependencies = TRUE) | |
install.packages('devtools') | |
devtools::install_github('inbo/fistools', auth_token = Sys.getenv("GITHUB_PAT")) | |
shell: Rscript {0} | |
- name: Install pkgdown | |
run: install.packages('pkgdown') | |
shell: Rscript {0} | |
- name: pull changes to branch if any | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git pull --rebase origin ${{ github.head_ref }} | |
- name: Build pkgdown site | |
run: pkgdown::build_site() | |
shell: Rscript {0} | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add -A | |
if ! git diff --cached --quiet; then | |
git commit -m 'Build pkgdown site [skip ci]' | |
# Extract the branch name from the full reference | |
BRANCH_NAME=${GITHUB_REF##*/} | |
git pull --rebase origin "$BRANCH_NAME" | |
git push origin "$BRANCH_NAME" # Push to the correct branch | |
else | |
echo "No changes to commit." | |
fi |