gh-pages #980
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: gh-pages | |
on: | |
push: | |
branches: [main, master] | |
pull_request: | |
branches: [main, master] | |
release: | |
types: [published] | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
update-pkg: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: r-lib/actions/setup-r@v2 | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- name: Install R pkg linux dependencies | |
run: | | |
sudo apt update | |
sudo apt-get install libcurl4-openssl-dev libnetcdf-dev libudunits2-dev libgdal-dev libharfbuzz-dev libfribidi-dev libfontconfig1-dev | |
shell: bash | |
- name: Install Rcpp | |
run: | | |
Rscript -e 'install.packages("Rcpp", repos = "https://RcppCore.github.io/drat")' | |
- name: Install devtools dependencies | |
run: | | |
Rscript -e 'install.packages(c("systemfonts", "textshaping"))' | |
- name: Install devtools | |
run: | | |
Rscript -e 'install.packages("devtools")' | |
- name: Install R pkgs | |
run: | | |
Rscript -e 'install.packages(c("dplyr", "here", "httr", "leaflet", "sf"))' | |
Rscript -e 'devtools::install_version("htmlwidgets", version = "1.6.2")' | |
- name: Update boemWind pkg | |
run: Rscript -e 'here::here("data-raw/dnld_get_boem_weas.R") |> source()' | |
- name: Install pkg | |
run: R CMD INSTALL . | |
- name: Create leaflet maps | |
run: Rscript -e 'here::here("data-raw/create_leaflet_maps.R") |> source()' | |
- name: Set up Git | |
run: | | |
git config --local user.email "actions@github.com" | |
git config --local user.name "GitHub Actions" | |
- name: Commit all changes | |
run: | | |
git add -A && git commit -m 'Downloaded BOEM WEAs' || echo "No changes to commit" | |
git push origin || echo "No changes to commit" | |
- name: Trigger workflow | |
run: | | |
curl -X POST \ | |
-H "Authorization: Bearer ${{ secrets.ACCESS_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/jmhatch-NOAA/READ-PSB-TE-WIND/actions/workflows/update_readme.yml/dispatches \ | |
-d '{"ref": "main"}' | |
- name: Build site | |
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) | |
shell: Rscript {0} | |
- name: Copy leaflet_maps | |
env: | |
SRC_FOLDER_PATH: 'leaflet_maps' | |
TARGET_BRANCH: 'gh-pages' | |
run: | | |
files=$(find $SRC_FOLDER_PATH -type f) # get the file list | |
git fetch # fetch branches | |
git checkout $TARGET_BRANCH # checkout to your branch | |
git rm -r $SRC_FOLDER_PATH # delete leaflet_maps folder (added) | |
git commit . -m "Deleting folder" # commit to the repository (added) | |
git push origin $TARGET_BRANCH # push to remote branch (added) | |
git checkout ${GITHUB_REF##*/} -- $files # copy files from the source branch | |
git add $files | |
git diff-index --quiet HEAD || git commit -am "No changes to commit" # commit to the repository (ignore if no modification) | |
git push origin $TARGET_BRANCH # push to remote branch | |
git checkout ${GITHUB_REF##*/} # checkout the source branch | |
git rm $files # delete files | |
git diff-index --quiet HEAD || git commit -am "No changes to commit" # commit to the repository (ignore if no modification) | |
git push origin # push to remote branch | |
- name: Deploy to GitHub pages 🚀 | |
if: github.event_name != 'pull_request' | |
uses: JamesIves/github-pages-deploy-action@v4.4.1 | |
with: | |
clean: false | |
branch: gh-pages | |
folder: docs |