Skip to content

version

version #471

Workflow file for this run

name: biocbook
on:
workflow_dispatch:
workflow_run:
workflows: ["dependencies"]
types:
- completed
branches:
- devel
- devel-*
- RELEASE_**
- sandbox
- sandbox-*
push:
branches:
- devel
- devel-*
- RELEASE_**
- sandbox
- sandbox-*
paths-ignore:
- 'README.md'
- 'deps.Dockerfile'
- 'DESCRIPTION'
jobs:
build:
# Only run if triggered by push/workflow_dispatch, or if triggered by workflow_run and the previous workflow succeeded
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
name: build-book (${{ github.ref_name }})
permissions:
contents: write
packages: write
steps:
- name: Free root space
uses: almahmoud/free-root-space@main
with:
verbose: true
- name: 🧾 Checkout repository
uses: actions/checkout@v4
- name: 🏷 Set Bioc version
run: |
branch="${{ github.ref_name }}"
if [[ "$branch" == "devel" || "$branch" =~ ^RELEASE_ ]]; then
# Remove everything after and including '-' if present
version=${branch%%-*}
echo "BIOC_VERSION=${version}" >> "${GITHUB_ENV}"
else
echo "BIOC_VERSION=devel" >> "${GITHUB_ENV}"
fi
- name: ⏳ Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@v2
- name: 🐳 Set up QEMU
uses: docker/setup-qemu-action@v3
- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 📝 Get book info
id: info
env:
OWNER: ${{ github.repository_owner }}
run: |
Pkgname=$(grep -m1 -E '^Package: +' DESCRIPTION | sed -E 's/.*: +//')
echo Pkgname=${Pkgname} >> "${GITHUB_ENV}"
pkgname=${Pkgname,,}
echo pkgname=${pkgname} >> "${GITHUB_ENV}"
owner=${OWNER,,}
echo owner=${owner} >> "${GITHUB_ENV}"
echo pkgversion=$(grep -m1 -E '^Version: +' DESCRIPTION | sed -E 's/.*: +//') >> "${GITHUB_ENV}"
- name: 🔐 Log in to the Github Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: 🏷 Get metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ env.owner }}/${{ env.pkgname }}
tags: |
type=raw,value={{branch}}
- name: 📦 Build and push book image
id: docker
uses: docker/build-push-action@v5
with:
context: .
file: biocbook.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
BRANCH=${{ steps.extract_branch.outputs.branch }}
OWNER=${{ env.owner }}
- name: 📚 Recover pkg artifacts generated during build in local Docker container (pkg bundle and book)
run: |
IMG_REF="$(echo ${{ steps.meta.outputs.tags }} | cut -d':' -f1)@$(echo ${{ steps.docker.outputs.ImageID }})"
docker pull $IMG_REF
SHA=$(docker container create $IMG_REF)
docker container cp ${SHA}:/opt/pkg/${{ env.Pkgname }}_${{ env.pkgversion }}.tar.gz .
tar --extract --gzip --file ${{ env.Pkgname }}_${{ env.pkgversion }}.tar.gz
echo bundle_path=${{ env.Pkgname }}_${{ env.pkgversion }}.tar.gz >> "${GITHUB_ENV}"
echo book_path=${{ env.Pkgname }}/inst/doc/book/ >> "${GITHUB_ENV}"
- name: 🏷 Get gh-branch directory to deploy to
run: |
echo target_folder=$(echo ${{ env.BIOC_VERSION }} | sed 's,RELEASE_,,' | tr '_' '.') >> "${GITHUB_ENV}"
- name: Upload static files as artifact
id: deployment
uses: actions/upload-pages-artifact@v3
with:
path: ${{ env.book_path }}/
- name: 💾 Upload package bundle artifact
uses: actions/upload-artifact@v4
with:
name: bundle
path: ${{ env.bundle_path }}
deploy:
# Only deploy for sandbox, regardless of whether this was a push or a workflow_run
if: >
(github.event_name != 'workflow_run' && github.ref == 'refs/heads/sandbox')
|| (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'sandbox')
needs: build
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4