build: add pkgdown GHA #1
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
# This workflow is used to update static webpage with documentation for the given GitHub repository. | |
# It's triggered by the push of the default branch. | |
# More details: https://docs.google.com/document/d/1WGW4_lOOZ73lEfVZwIWMivbyCgDTJAajxP5N8767DZY | |
name: pkgdown | |
on: | |
push: | |
branches: [main, master, test_ci_pkgdown] | |
release: | |
types: [published] | |
workflow_call: | |
inputs: | |
USERNAME: | |
required: true | |
type: string | |
PACKAGE_NAME: | |
required: true | |
type: string | |
BRANCH_NAME: | |
required: true | |
type: string | |
IS_SUBDIR: | |
description: "Is the R package stored as the subdirectory of the repository?" | |
required: false | |
type: string | |
default: 'false' | |
secrets: | |
PRIVATE_ACCESS_TOKEN: | |
required: true | |
permissions: | |
contents: write | |
jobs: | |
pkgdown: | |
runs-on: ubuntu-latest | |
# Only restrict concurrency for non-PR jobs | |
concurrency: | |
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} | |
env: | |
GITHUB_PAT: ${{ secrets.PRIVATE_ACCESS_TOKEN }} | |
TEST_TAG: user/app:latest-${{ github.sha }} | |
USERNAME: ${{ github.actor }} | |
PACKAGE_NAME: ${{ github.event.repository.name }} | |
BRANCH_NAME: ${{ github.head_ref }} | |
BASE_IMAGE: marcinkam/gdrshiny:1.0 | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
fetch-depth: 0 | |
ref: ${{ env.BRANCH_NAME }} | |
tags: ${{ env.TEST_TAG }} | |
build-args: | | |
GITHUB_TOKEN=${{ secrets.PRIVATE_ACCESS_TOKEN }} | |
BASE_IMAGE=${{ env.BASE_IMAGE }} | |
- name: Run pkgdown | |
if: ${{ inputs.IS_SUBDIR != 'true' }} | |
run: | | |
docker run -v `pwd`:/mnt/vol ${{ env.TEST_TAG }} Rscript -e 'pkgdown::build_site_github_pages("/mnt/vol", new_process = FALSE, install = FALSE)' | |
# currently, internal packages are stored as subdirectories in the repository | |
# eventually, this loop becomes obsolete (subdirectory structure is not allowed in Bioconductor)) | |
- name: Run pkgdown (R package as subdirectory) | |
if: ${{ inputs.IS_SUBDIR == 'true' }} | |
run: | | |
docker run -v $GITHUB_WORKSPACE:/mnt/vol ${{ env.TEST_TAG }} bash -c "find /mnt/vol/${{ env.PACKAGE_NAME }}" | |
docker run -v `pwd`:/mnt/vol ${{ env.TEST_TAG }} Rscript -e 'pkgdown::build_site_github_pages("/mnt/vol/${{ env.PACKAGE_NAME }}", new_process = FALSE, install = FALSE)' | |
- name: Deploy to GitHub pages 🚀 | |
if: ${{ inputs.IS_SUBDIR != 'true' }} | |
uses: JamesIves/[email protected] | |
with: | |
clean: true | |
branch: pages | |
folder: docs | |
target-folder: docs | |
- name: Deploy to GitHub pages 🚀 (R package as subdirectory) | |
if: ${{ inputs.IS_SUBDIR == 'true' }} | |
uses: JamesIves/[email protected] | |
with: | |
clean: true | |
branch: pages | |
folder: ${{ env.PACKAGE_NAME }}/docs | |
target-folder: docs |