Skip to content

fix docker build action #3

fix docker build action

fix docker build action #3

Workflow file for this run

name: Build Docker image
# adapted from https://github.com/scverse/scvi-tools/blob/main/.github/workflows/build_image_latest.yaml
on:
workflow_run:
workflows: ["Release"]
types:
- completed
workflow_dispatch:
push:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash -e {0} # -e to fail on error
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set build inputs
id: build
run: |
INPUT_REF=${{ github.ref_name }}
if [[ $INPUT_REF == "main" ]]; then
VERSION="latest"
else
VERSION=${INPUT_REF}
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
cache-from: type=registry,ref=${{ env.REGISTRY }}/scverse/spatialdata:buildcache
cache-to: type=inline,ref=${{ env.REGISTRY }}/scverse/spatialdata:buildcache
tags: ${{ env.REGISTRY }}/scverse/spatialdata:${{ steps.build.outputs.version }}