Skip to content

Commit

Permalink
[ci/cd] add in automatic website build PR on push to main
Browse files Browse the repository at this point in the history
  • Loading branch information
immanuelazn authored Oct 23, 2024
2 parents 334f172 + 6251905 commit ed1439c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build and Deploy Docs
on:
push:
branches:
- main
jobs:
build_docs:
name: Build and Deploy Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # to ensure other branches are available for build
- name: Install system dependencies
run: sudo apt-get install -y libhdf5-dev
- name: Set r compilation options
run: bash -c 'echo -e "MAKEFLAGS=--jobs=3\nCXXFLAGS += -O1 -UNDEBUG" > "$GITHUB_WORKSPACE/Makevars.user" && echo "R_MAKEVARS_USER=$GITHUB_WORKSPACE/Makevars.user" >> "$GITHUB_ENV"'
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Install R dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
cache-version: 1
working-directory: 'r'
extra-packages: |
any::pkgdown
any::devtools
- name: Get last commit message
id: last_commit
run: |
{
echo 'LAST_COMMIT_MESSAGE<<EOF'
git log -n 1
echo 'EOF'
} >> "$GITHUB_ENV"
- name: Create git worktree with docs branch
run: git worktree add r/docs docs-html
- name: Build documentation
run: |
Rscript .github/workflows/deploy-reference.R
- name: Configure Git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Create new branch
run: |
git checkout -b update-docs-$(git rev-parse --short=6 ${{ github.sha }})
git add .
git commit -m "Update documentation for commit $(git rev-parse --short=6 ${{ github.sha }})"
working-directory: r/docs
- name: Push changes to new branch
run: git push origin update-docs-$(git rev-parse --short=6 ${{ github.sha }})
- name: Create Pull Request # use message with last commit
run: |
gh pr create --title "Update docs for commit: $(git log -n 1 --pretty=%B)" --body "$LAST_COMMIT_MESSAGE" --base docs-html --head update-docs-$(git rev-parse --short=6 ${{ github.sha }})
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .github/workflows/deploy-reference.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
devtools::document('r')
pkgdown::build_reference('r')
pkgdown::build_news('r')
pkgdown::build_home('r')

0 comments on commit ed1439c

Please sign in to comment.