Build and deploy Apptainer image #20
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: Check out the repository | |
| uses: actions/checkout@v4 | |
| - name: Verify Git repository and working directory | |
| run: | | |
| echo "Current directory: $(pwd)" | |
| echo "Listing contents:" | |
| ls -la # List contents to see if the repository exists | |
| git status # Verify that Git can see the repo | |
| - name: Install git | |
| run: | | |
| apk update | |
| apk add git | |
| git config --global --add safe.directory "$GITHUB_WORKSPACE" # Ensure the workspace is safe | |
| - name: Get latest tag | |
| id: tag | |
| run: | | |
| cd "$GITHUB_WORKSPACE" # Explicitly set the correct directory | |
| echo "Current directory: $(pwd)" # Debug: Check if we're in the correct directory | |
| ls -la # List contents again to ensure we're in the right repo | |
| git status # Verify Git is working inside the container | |
| 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 }} |