Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 83 additions & 35 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker build
name: Docker build & smoke test

on:
workflow_dispatch:
Expand All @@ -24,41 +24,89 @@ jobs:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 200
fetch-tags: true
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 200
fetch-tags: true

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TARGET_BRANCH }}
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags[0] }}
cache-to: type=inline
env:
TARGET_BRANCH: ${{ github.base_ref || github.ref_name }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TARGET_BRANCH }}
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags[0] }}
cache-to: type=inline
env:
TARGET_BRANCH: ${{ github.base_ref || github.ref_name }}

smoke-test:
runs-on: docker
steps:
- uses: actions/checkout@v5
- uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y --no-install-recommends graphviz
- name: Check if data needs to be pulled
run: |
if [ ! -d "test/data" ]; then
echo "Fetching data..."
uv run petprep/scripts/collect_test_data.py -o bids -d smriprep freesurfer
fi
- name: Install PETPrep wrapper
run: |
uv tool install petprep/wrapper
- name: Run PETPrep smoke test
run: |
uvx petprep_wrapper bids derivatives/output participant -i $PETPREP_DOCKER_IMAGE --participant-label 01
env:
PETPREP_DOCKER_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags[0] }}

push-container:
if: github.event_name != 'pull_request'
needs: build-container
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
Loading