Updated workflow #11
Workflow file for this run
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: Singularity Build | |
on: | |
push: | |
tags: | |
- sif-*-v*.* | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
name: Build Apptainer image | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Delete huge unnecessary tools folder | |
run: rm -rf /opt/hostedtoolcache; echo "Done removing /opt/hostedtoolcache" | |
- name: Delete .NET, Android, Haskell tools to free space | |
run: rm -rf /usr/share dotnet; rm -rf /usr/local/lib/android; rm -rf /opt/ghc; echo "Done removing .NET, Android, and Haskell tools." | |
- name: Install Apptainer | |
run: deb=$(curl -w "%{filename_effective}" -LO https://github.com/apptainer/apptainer/releases/download/v1.2.4/apptainer_1.2.4_amd64.deb) && sudo apt install -y "./$deb"; rm -f "$deb"; unset deb | |
- name: Check out code for the container build | |
uses: actions/checkout@v4 | |
- name: Build Container | |
run: | | |
cont_name=$(echo "${GITHUB_REF_NAME:-}" | sed -E 's/^sif-//; s/-v[0-9]+[.].*$//') | |
echo "Container name is $cont_name." | |
[ -d "${cont_name:-}" ] || exit 1 | |
pushd "${cont_name}" | |
apptainer build --fakeroot --fix-perms --warn-unused-build-args --build-arg ORAS_REPO="ghcr.io/${{ github.repository }}" ../${cont_name}.sif Singularity | |
popd | |
apptainer cache clean -f | |
tag="${tag:-latest}" | |
echo "Tag is $tag." | |
echo "tag=$tag" >> $GITHUB_ENV | |
echo "cont_name=$cont_name" >> $GITHUB_ENV | |
- name: Login and Deploy Container | |
run: | | |
[ -r "${cont_name}.sif" ] || exit 1 | |
apptainer remote login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io | |
apptainer push "${cont_name}.sif" oras://ghcr.io/${{ github.repository }}/${cont_name}:${tag} | |
rm -f "${cont_name}.sif" | |