Skip to content

Merge pull request #494 from moritzgubler/property/hirshfeld #62

Merge pull request #494 from moritzgubler/property/hirshfeld

Merge pull request #494 from moritzgubler/property/hirshfeld #62

name: Singularity Build (docker)
on:
push:
branches:
- master
release:
types:
- published
jobs:
build-test-containers:
runs-on: ubuntu-latest
strategy:
# Keep going on other deployments if anything bloops
fail-fast: false
matrix:
singularity_version:
- '3.9.2'
program:
- 'mrchem'
variant:
- 'nompi'
- 'openmpi4.0'
container:
image: quay.io/singularity/singularity:v${{ matrix.singularity_version }}
options: --privileged
name: Build ${{ matrix.program }}-${{ matrix.variant }}
steps:
- name: Check out code for the container builds
uses: actions/checkout@v2
- name: Build container
env:
image_name: ${{ matrix.program }}_${{ matrix.variant }}
recipe_name: Singularity.${{ matrix.variant }}
run: |
echo "Building ${{ matrix.program }} ${{ matrix.variant }}"
echo "GITHUB_REF: ${GITHUB_REF}"
echo "GITHUB_SHA: ${GITHUB_SHA}"
echo "GITHUB_EVENT_NAME: $GITHUB_EVENT_NAME"
echo "IMAGE_NAME=$image_name" >> $GITHUB_ENV
# build container
sudo -E singularity build container.sif recipes/"$recipe_name"
# determine release tag
if [[ ${GITHUB_EVENT_NAME} == "release" ]]; then
# give release events tag "vX.Y.Z" (GITHUB_REF=refs/tags/vX.Y.Z)
tag=$(basename $GITHUB_REF)
else
# give push events on master tag "latest"
tag="latest"
fi
# Build the container and name by tag
echo "TAG=$tag" >> $GITHUB_ENV
- name: Login and deploy container
run: |
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io
echo "Pushing $IMAGE_NAME with tag $TAG"
singularity push container.sif oras://ghcr.io/${GITHUB_REPOSITORY}/${IMAGE_NAME}:${TAG}