|
| 1 | +name: Upload Singularity Images |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Upload Docker Images"] |
| 6 | + types: [completed] |
| 7 | + branches: [main, master] |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + release_tag: |
| 11 | + description: 'Release tag to build Singularity image for' |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github. workflow }}-${{ github.ref }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + push_singularity: |
| 21 | + name: Push Singularity image to registry |
| 22 | + runs-on: ubuntu-latest |
| 23 | + # Only run if the Docker workflow succeeded, or if manually triggered |
| 24 | + if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} |
| 25 | + permissions: |
| 26 | + packages: write |
| 27 | + contents: read |
| 28 | + steps: |
| 29 | + - name: Check out the repo |
| 30 | + uses: actions/checkout@v3 |
| 31 | + with: |
| 32 | + ref: ${{ github. event.inputs.release_tag || github.event.workflow_run.head_branch }} |
| 33 | + |
| 34 | + - name: Set up Singularity |
| 35 | + uses: eWaterCycle/setup-singularity@v7 |
| 36 | + with: |
| 37 | + singularity-version: 3.8.7 |
| 38 | + |
| 39 | + - name: Log in to GitHub Container Registry for Singularity |
| 40 | + run: | |
| 41 | + echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io |
| 42 | + |
| 43 | + - name: Determine tag |
| 44 | + id: tag |
| 45 | + run: | |
| 46 | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
| 47 | + TAG="${{ github.event. inputs.release_tag }}" |
| 48 | + else |
| 49 | + # Extract tag from the triggering workflow |
| 50 | + TAG="${{ github.event.workflow_run.head_branch }}" |
| 51 | + fi |
| 52 | + echo "tag=${TAG}" >> $GITHUB_OUTPUT |
| 53 | + |
| 54 | + - name: Build and push Singularity images |
| 55 | + run: | |
| 56 | + TAG="${{ steps.tag.outputs. tag }}" |
| 57 | + |
| 58 | + # Build Singularity image from the Docker image |
| 59 | + singularity build pyprophet.sif docker://ghcr.io/${{ github.repository }}:${TAG} |
| 60 | + |
| 61 | + # Push to GHCR with -sif suffix |
| 62 | + singularity push pyprophet.sif oras://ghcr.io/${{ github.repository }}-sif:${TAG} |
| 63 | + |
| 64 | + # Also tag as latest if appropriate |
| 65 | + if [ "${{ github.event_name }}" == "workflow_run" ] || [ -n "${{ github. event.inputs.release_tag }}" ]; then |
| 66 | + singularity push pyprophet. sif oras://ghcr.io/${{ github.repository }}-sif:latest |
| 67 | + fi |
0 commit comments