Skip to content

release

release #238

Workflow file for this run

name: release
on:
schedule:
- cron: '19 4 * * *'
push:
branches: [ main ]
env:
LATEST: '2.39.0'
REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
singularity:
runs-on: ubuntu-latest
container:
image: quay.io/singularity/singularity:v3.11.5
strategy:
fail-fast: false
matrix:
recipe: ["Singularity"]
steps:
- name: Check out code for the container build
uses: actions/checkout@v4
- name: Continue if Singularity recipe exists
run: |
if [[ -f "${{ matrix.recipe }}" ]]; then
echo "keepgoing=true" >> $GITHUB_ENV
fi
- name: Get branch name
run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
# - name: Update Singularity file tag
# if: github.event_name != 'pull_request'
# run: |
# sed -i "s/latest/$BRANCH/" ./Singularity
- name: Build Singularity image
if: ${{ env.keepgoing == 'true' }}
env:
recipe: ${{ matrix.recipe }}
run: |
ls
if [ -f "${{ matrix.recipe }}" ]; then
sudo -E singularity build container.sif ${{ matrix.recipe }}
tag=$(echo "${recipe/Singularity\./}")
if [ "$tag" == "Singularity" ]; then
tag=$BRANCH
fi
# Build the container and name by tag
echo "Tag is $tag."
echo "tag=$tag" >> $GITHUB_ENV
else
echo "${{ matrix.recipe }} is not found."
echo "Present working directory: $PWD"
ls
fi
- name: Login and Deploy Container
env:
keepgoing: ${{ env.keepgoing }}
run: |
if [[ "${keepgoing}" == "true" ]]; then
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io
singularity push container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${tag}
fi
- name: Login and Deploy Latest Container
if: env.BRANCH == env.LATEST
env:
keepgoing: ${{ env.keepgoing }}
run: |
if [[ "${keepgoing}" == "true" ]]; then
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io
singularity push container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:latest
fi