Skip to content

Commit

Permalink
Push singularity .sif files to ghcr.io with tags
Browse files Browse the repository at this point in the history
Fixes #12
  • Loading branch information
espenhgn committed May 2, 2024
1 parent 2c78524 commit 582eee8
Showing 1 changed file with 70 additions and 4 deletions.
74 changes: 70 additions & 4 deletions .github/workflows/docker_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,33 @@ on:
push:
branches:
- 'main'
tags:
- "v*.*.*"

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/ldpred2
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
-
name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
Expand All @@ -26,8 +41,59 @@ jobs:
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:docker"
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/ldpred2:latest
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
file:
./dockerfiles/ldpred2/Dockerfile
platforms: linux/amd64

build-push-singularity-container:
needs: docker
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
container:
image: quay.io/singularity/singularity:v4.1.0
options: --privileged
name: Pull-push Singularity Container
steps:
- name: Check out code for the container builds
uses: actions/checkout@v4
- name: Install dependencies
run: |
apk add --no-cache curl
VERSION="1.1.0"
curl -LO "https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_amd64.tar.gz"
mkdir -p oras-install/
tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/
sudo mv oras-install/oras /usr/local/bin/
rm -rf oras_${VERSION}_*.tar.gz oras-install/
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/ldpred2
tags: |
type=semver,pattern={{version}}
type=ref,event=branch
type=sha
- name: Pull and push Singularity container
run: |
tags="${{ steps.meta.outputs.tags }}"
tags_array=
old_ifs="$IFS"
IFS=$'\n'
for tag in $tags; do
tags_array="$tags_array $tag"
done
IFS="$old_ifs"
echo ${{ secrets.GITHUB_TOKEN }} | oras login --username ${{ github.repository_owner }} --password-stdin ghcr.io
for tag in $tags_array; do
echo "processing tag: $tag"
singularity pull ldpred2.sif docker://"$tag"
oras push "$tag" --artifact-type application/vnd.acme.rocket.config ldpred2.sif
rm ldpred2.sif
done
shell: sh

0 comments on commit 582eee8

Please sign in to comment.