Skip to content

Deploy Apptainer

Deploy Apptainer #5

name: Deploy Apptainer
on:
workflow_run:
workflows: ["release-please"]
types:
- completed
workflow_dispatch:
jobs:
build_and_push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
- name: checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: add apptainer source
shell: bash
run: |
sudo add-apt-repository -y ppa:apptainer/ppa
sudo apt-get update
- name: create dockerfile
uses: snakemake/snakemake-github-action@v2
with:
directory: .
snakefile: workflow/Snakefile
install-apptainer: true
args: "--cores 1"
task: containerize
- name: create apptainer recipe
shell: bash
run: |
pip install spython
sed -i "2i RUN apt-get update && apt-get install -y curl" Dockerfile
spython recipe Dockerfile > apptainer.def
sed -i 's/\/environment.yaml\/environment.yaml$/\/environment.yaml/' apptainer.def
- name: create apptainer image
shell: bash
run: |
sudo apt-get install -y uidmap
apptainer build --fakeroot apptainer.sif apptainer.def
- name: authenticate to GHCR
run: |
echo ${{ secrets.GITHUB_TOKEN }} | apptainer registry login -u ${{ github.actor }} --password-stdin oras://ghcr.io
- name: push apptainer to GHCR
run: |
REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "Pushing apptainer to: oras://ghcr.io/${REPO}:latest"
apptainer push apptainer.sif "oras://ghcr.io/${REPO}:latest"