Build Apptainer Images #70
This file contains hidden or 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
name: Build Apptainer Images | |
on: | |
workflow_dispatch: | |
workflow_run: | |
workflows: ["Build container images for GHCR and Dockerhub"] | |
types: | |
- completed | |
jobs: | |
build-apptainer: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
base: | |
- {image: 'ghcr.io/bioconductor/r-ver', outname: 'r-ver'} | |
- {image: 'ghcr.io/bioconductor/bioconductor', outname: 'bioconductor'} | |
- {image: 'ghcr.io/bioconductor/tidyverse', outname: 'tidyverse'} | |
- {image: 'ghcr.io/bioconductor/shiny', outname: 'shiny'} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Apptainer dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
autoconf \ | |
automake \ | |
cryptsetup \ | |
fuse2fs \ | |
git \ | |
fuse \ | |
libfuse-dev \ | |
libseccomp-dev \ | |
libtool \ | |
pkg-config \ | |
runc \ | |
squashfs-tools \ | |
squashfs-tools-ng \ | |
uidmap \ | |
wget \ | |
zlib1g-dev \ | |
libsubid-dev | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.24.1 | |
- name: Install Apptainer | |
run: | | |
export VERSION=1.3.6 # Latest Apptainer version as of 2025-04 | |
wget https://github.com/apptainer/apptainer/releases/download/v${VERSION}/apptainer-${VERSION}.tar.gz | |
tar -xzf apptainer-${VERSION}.tar.gz | |
cd apptainer-${VERSION} | |
./mconfig | |
make -C ./builddir | |
sudo make -C ./builddir install | |
- name: Verify Apptainer config | |
run: apptainer buildcfg | |
- name: Get branch name | |
id: vars | |
shell: bash | |
run: | | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
PROCESSED_NAME="$BRANCH_NAME" | |
if [[ $BRANCH_NAME == RELEASE_* ]]; then | |
PROCESSED_NAME=${BRANCH_NAME#RELEASE_} | |
PROCESSED_NAME=${PROCESSED_NAME//_/.} | |
fi | |
echo "origbranch=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
echo "procbranch=$PROCESSED_NAME" >> $GITHUB_OUTPUT | |
- name: Build Apptainer Image | |
run: | | |
apptainer build \ | |
"${{matrix.base.outname}}-$(date +%s).sif" \ | |
docker://${{ matrix.base.image }}:${{steps.vars.origbranch}} | |
- name: Push to GitHub Packages | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | apptainer remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io | |
apptainer push *.sif oras://ghcr.io/${{github.repository_owner}}/${{matrix.base.outname}}:${{steps.vars.origbranch}} | |
apptainer push *.sif oras://ghcr.io/${{github.repository_owner}}/${{matrix.base.outname}}:${{steps.vars.procbranch}} |