From 4c6a2e1fa5d07af7757473e9c843e789eb9f3120 Mon Sep 17 00:00:00 2001 From: Arkadiusz Gladki Date: Wed, 28 Feb 2024 16:36:21 +0100 Subject: [PATCH] build: add pkgdown GHA --- .github/workflows/pkgdown.yaml | 93 ++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .github/workflows/pkgdown.yaml diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..8781636 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,93 @@ +# 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/github-pages-deploy-action@v4.5.0 + 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/github-pages-deploy-action@v4.5.0 + with: + clean: true + branch: pages + folder: ${{ env.PACKAGE_NAME }}/docs + target-folder: docs