Merge pull request #38 from WEHI-ResearchComputing/MihinP-patch-2 #60
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: Singularity Build | |
| on: | |
| push: | |
| branches: ['main'] | |
| pull_request: | |
| jobs: | |
| build-test-containers: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| # Keep going on other deployments if anything bloops | |
| fail-fast: false | |
| matrix: | |
| singularity_version: | |
| - '3.8.1' | |
| container: | |
| image: quay.io/singularity/singularity:v${{ matrix.singularity_version }} | |
| options: --privileged | |
| steps: | |
| - name: Check out code for the container builds | |
| uses: actions/checkout@v2 | |
| with: | |
| submodules: recursive | |
| - name: Build Container | |
| run: | | |
| if [ -f Singularity ]; then | |
| sudo -E singularity build container.sif Singularity | |
| else | |
| echo "Singularity is not found." | |
| echo "Present working directory: $PWD" | |
| ls | |
| fi | |
| - name: Set Tag Based on Branch Name | |
| run: | | |
| # Get the branch name and set it as the tag | |
| tag=${GITHUB_REF##*/}-singularity | |
| echo "Tag is $tag." | |
| echo "tag=$tag" >> $GITHUB_ENV | |
| - name: Login and Deploy Container | |
| if: (github.event_name != 'pull_request') | |
| run: | | |
| echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io | |
| container_name=$(echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]') | |
| singularity push container.sif oras://ghcr.io/${container_name}:${tag} |