Build & publish containers #43
Workflow file for this run
This file contains 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 & publish containers | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
jobs: | |
push_docker_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: bids/validator | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push_singularity_to_registry: | |
runs-on: ubuntu-latest | |
needs: | |
- push_docker_to_registry | |
steps: | |
- name: Set up Go 1.13 | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.13 | |
id: go | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update && sudo apt-get install -y \ | |
build-essential \ | |
libssl-dev \ | |
uuid-dev \ | |
libgpgme11-dev \ | |
squashfs-tools \ | |
libseccomp-dev \ | |
pkg-config | |
- name: Install Singularity | |
env: | |
SINGULARITY_VERSION: 3.8.0 | |
GOPATH: /tmp/go | |
run: | | |
mkdir -p $GOPATH | |
sudo mkdir -p /usr/local/var/singularity/mnt && \ | |
mkdir -p $GOPATH/src/github.com/sylabs && \ | |
cd $GOPATH/src/github.com/sylabs && \ | |
wget -qO- https://github.com/sylabs/singularity/releases/download/v${SINGULARITY_VERSION}/singularity-ce-${SINGULARITY_VERSION}.tar.gz | \ | |
tar xzv && \ | |
cd singularity-ce-${SINGULARITY_VERSION} && \ | |
./mconfig -p /usr/local && \ | |
make -C builddir && \ | |
sudo make -C builddir install | |
- name: Check out code for the container build | |
uses: actions/checkout@v4 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: bids/validator | |
- name: Build Container | |
run: | | |
tags=${{ steps.meta.outputs.tags }} | |
echo $tags | |
singularity pull container.sif docker://${tags%,*} | |
- name: Login and Deploy Container | |
if: (github.event_name != 'pull_request') | |
run: | | |
tags=${{ steps.meta.outputs.tags }} | |
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io | |
for tag in $(echo $tags | sed "s/,/ /g" | sed "s/bids\/validator/bids-standard\/bids-validator/g"); | |
do echo $tag; singularity push container.sif oras://ghcr.io/$tag; done |