Build and deploy Apptainer image #22
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 and deploy Apptainer image | |
on: | |
workflow_run: | |
workflows: ["Build and deploy PyPI package"] | |
types: [completed] | |
workflow_dispatch: # This allows manual triggering | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
container: | |
image: kaczmarj/apptainer:latest | |
options: --privileged | |
name: Build and deploy container | |
steps: | |
- name: Install git | |
run: | | |
apk update | |
apk add --no-cache git | |
git config --global --add safe.directory "$GITHUB_WORKSPACE" # Ensure the workspace is safe | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Get latest tag | |
id: tag | |
run: | | |
git fetch --tags | |
if ! LATEST_TAG=$(git describe --tags --abbrev=0); then | |
echo "::error::No tags found in repository" | |
exit 1 | |
fi | |
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV | |
- name: Build SIF image | |
run: | | |
apptainer build bidscoin.sif apptainer.def | |
- name: Login and deploy container | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | apptainer registry login -u "${{ github.actor }}" --password-stdin oras://ghcr.io | |
apptainer push bidscoin.sif oras://ghcr.io/donders-institute/bidscoin:${{ env.LATEST_TAG }} |