trigger-singularity-build #78
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
name: Build & Deploy Singularity Containers | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: [trigger-singularity-build] | |
jobs: | |
build-test-deploy-singularity: | |
runs-on: ubuntu-latest | |
container: | |
image: quay.io/singularity/singularity:v3.8.3 # v4 cannot acces oras://ghcr.io | |
env: | |
SPM_TAG: "24.10.alpha21" | |
strategy: | |
fail-fast: false | |
matrix: | |
recipe: ["matlab", "octave"] | |
name: Build ${{ matrix.recipe }} | |
steps: | |
- name: Set environment variables for repository_dispatch | |
if: ${{ github.event_name == 'repository_dispatch' }} | |
run: echo "SPM_TAG=${{ github.event.client_payload.spm_tag }}" >> $GITHUB_ENV | |
# Pull the Docker image with Singularity and convert it to a SIF file | |
- name: Build Singularity image from Docker | |
run: | | |
singularity pull docker://ghcr.io/spm/spm-docker:docker-${{matrix.recipe}}-${{env.SPM_TAG}} | |
mv spm-docker_docker-${{matrix.recipe}}-${{env.SPM_TAG}}.sif spm.sif | |
- name: Login and Deploy Container | |
if: ${{ github.repository_owner }} == 'spm' | |
run: | | |
tag=singularity-${{ matrix.recipe }}-${{ env.SPM_TAG }} | |
latest_tag=singularity-${{ matrix.recipe }}-latest | |
echo "Tag is $tag." | |
singularity remote add oras ghcr.io | |
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io | |
singularity push spm.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${tag} | |
singularity push spm.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${latest_tag} |