chore: update pre-commit hooks (#296) #10
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: Docker Build | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
paths: | |
- "src/**" | |
- "tests/**" | |
- "resources/docker/Dockerfile" | |
- "resources/docker/*.lock" | |
- "resources/docker/*.yaml" | |
- "resources/docker/*.sh" | |
- ".github/workflows/image_ci.yml" | |
pull_request: | |
branches: | |
- "dev-**" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
FORCE_COLOR: 3 | |
DOCKER_REGISTRY: ghcr.io | |
DOCKER_ORG: ${{ github.repository_owner }} | |
GITHUB_SHA: ${{ github.sha }} | |
GITHUB_REF: ${{ github.ref }} | |
GITHUB_HEAD_REF: ${{ github.head_ref }} | |
GITHUB_REF_NAME: ${{ github.ref_name }} | |
PROJECT_NAME: caustics | |
jobs: | |
build-images: | |
name: build-image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
# Currently need to be hardcoded | |
# for more version, will need to modify | |
# the conda environment to be able | |
# to install different versions of CUDA | |
CUDA_VERSION: ["11.8.0"] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Get registry and org | |
id: registry_org | |
run: | | |
ORG=$(echo "${DOCKER_ORG}" | tr '[:upper:]' '[:lower:]') | |
echo "image_base=${DOCKER_REGISTRY}/${ORG}" >> $GITHUB_OUTPUT | |
- name: Get short github sha | |
id: github_sha | |
run: | | |
SHA7="${GITHUB_SHA::7}" | |
echo "short_sha=${SHA7}" >> $GITHUB_OUTPUT | |
- name: Extract branch name | |
id: extract_branch | |
run: | |
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> | |
$GITHUB_OUTPUT | |
# https://github.com/actions/runner-images/issues/2840#issuecomment-790492173 | |
- name: Free up disk space | |
run: | | |
df -h | |
docker image ls | |
sudo apt clean | |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc | |
df -h | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | |
${{ steps.registry_org.outputs.image_base }}/${{ env.PROJECT_NAME }} | |
tags: | | |
type=raw,value=${{ steps.extract_branch.outputs.branch }}-cuda-${{ matrix.CUDA_VERSION }} | |
type=raw,value=${{ steps.github_sha.outputs.short_sha }}-cuda-${{ matrix.CUDA_VERSION }} | |
- name: Log in to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./resources/docker/Dockerfile | |
platforms: linux/amd64 | |
load: | |
${{ !contains(fromJSON('["refs/heads/main", "refs/heads/dev"]'), | |
env.GITHUB_REF) }} | |
push: | |
${{ contains(fromJSON('["refs/heads/main", "refs/heads/dev"]'), | |
env.GITHUB_REF) }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
CAUSTICS_VERSION=${{ steps.extract_branch.outputs.branch }} | |
CUDA_VERSION=${{ matrix.CUDA_VERSION }} | |
- name: Inspect Image | |
if: ${{ env.GITHUB_REF != 'refs/heads/main' }} | |
run: | | |
docker run ${{ steps.registry_org.outputs.image_base }}/${{ env.PROJECT_NAME }}:${{ steps.github_sha.outputs.short_sha }}-cuda-${{ matrix.CUDA_VERSION }} micromamba list | |
docker image ls |