From 198701c84058ff5487544ea3f05e7e546667f772 Mon Sep 17 00:00:00 2001 From: Benjamin Smith <46410142+benyamindsmith@users.noreply.github.com> Date: Tue, 29 Oct 2024 21:14:50 -0400 Subject: [PATCH] Create build-and-deploy.yml --- .github/workflows/build-and-deploy.yml | 50 ++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/build-and-deploy.yml diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 0000000..b462e8f --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,50 @@ +name: R Package Build and Deploy + +on: + push: + branches: + - main # Trigger on pushes to the main branch. You can change this to any branch you like. + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up R + uses: r-lib/actions/setup-r@v2 + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y libcurl4-openssl-dev libxml2-dev libssl-dev pandoc + + - name: Install R dependencies + run: | + install.packages('devtools') + install.packages('usethis') + install.packages('pkgdown') # for building the site + + - name: Build and document R package (conditionally) + if: | + github.event.head_commit.message != 'skip-build' && + (contains(github.event.head_commit.message, "R/") || contains(github.event.head_commit.message, "man/") || contains(github.event.head_commit.message, "DESCRIPTION") || contains(github.event.head_commit.message, "NAMESPACE")) + run: | + R -e "devtools::document()" + R -e "devtools::build()" + + - name: Build site + run: | + R -e "usethis::build_site()" + + - name: Commit built site and push + run: | + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + git add docs/ + git commit -m "Update site on commit ${{ github.sha }}" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}