refresh-extdata #388
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
on: | |
schedule: | |
- cron: '0 6 * * 1' | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- .github/workflows/R-CMD-check.yml | |
- .github/workflows/refresh-extdata.yml | |
workflow_dispatch: | |
name: refresh-extdata | |
jobs: | |
render: | |
name: refresh-extdata | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- {os: ubuntu-latest, r: 'release'} | |
env: | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
clean: 'false' | |
- name: Get branch name (manual) | |
if: github.event_name != 'pull_request' | |
shell: bash | |
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV | |
- name: Get branch name (pull request) | |
if: github.event_name == 'pull_request' | |
shell: bash | |
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV | |
- name: Configure git | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "SoilKnowledgeBot" | |
git pull --no-rebase origin ${{ env.BRANCH_NAME }} | |
echo ${{ env.BRANCH_NAME }} | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.config.r }} | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
extra-packages: any::rcmdcheck, any::remotes, any::pdftools, any::rvest, any::xml2, any::aqp, any::soilDB, any::data.table, any::R.utils, any::terra | |
needs: check | |
- name: Install SoilKnowledgeBase | |
run: | | |
sudo apt install poppler-utils | |
cd .. | |
R CMD build SoilKnowledgeBase | |
R CMD INSTALL SoilKnowledgeBase | |
cd SoilKnowledgeBase/ | |
- name: Install Rmarkdown | |
run: Rscript -e 'install.packages("rmarkdown")' | |
- name: Render README | |
run: Rscript -e 'rmarkdown::render("README.Rmd")' | |
- name: Post-processing | |
run: | | |
Rscript misc/OSD-error-reporting/typical-pedon.R | |
Rscript misc/OSD-error-reporting/osd-sections.R | |
- name: Commit results | |
run: | | |
git add inst/extdata/\*.txt | |
git commit -m 'Update inst/extdata/ TXT files' || echo "No changes to commit" | |
# git add inst/extdata/\*.html | |
# git commit -m 'Update inst/extdata/ HTML files' || echo "No changes to commit" | |
git add inst/extdata/\*.json | |
git commit -m 'Update inst/extdata/ JSON files' || echo "No changes to commit" | |
git add inst/extdata/\*.csv | |
git commit -m 'Update inst/extdata/ CSV files' || echo "No changes to commit" | |
git commit README.md -m 'Render README.Rmd' || echo "No changes to commit" | |
- name: Push results | |
run: | | |
git push origin HEAD:${{ env.BRANCH_NAME }} || echo "No changes to commit" | |
- name: Upload snapshot to release | |
if: github.ref == 'refs/heads/main' && hashFiles('inst/extdata/NSSH/NSSH.pdf') != '' | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: inst/extdata/NSSH/NSSH.pdf | |
tag: snapshot | |
file_glob: true | |
overwrite: true | |
body: "Download the National Soil Survey Handbook (NSSH) as a single PDF. This PDF is built weekly from the latest eDirectives sources." |