refactor: Update how the codebase is structured #9
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
# Any commit to master branch re-builds images, re-runs tests, and pushes SHA tags to DockerHub | |
name: Build | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'LICENSE' | |
- 'README.md' | |
workflow_dispatch: | |
env: | |
DOCKER_REGISTRY: ghcr.io | |
DOCKER_ORG: ${{ github.repository_owner }} | |
GITHUB_SHA: ${{ github.sha }} | |
GITHUB_REF: ${{ github.ref }} | |
PROJECT_NAME: caustics | |
jobs: | |
build-images: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
CAUSTICS_VERSION: ["dev", "0.7.0"] | |
CUDA_VERSION: ["11.8.0"] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Get registry and org | |
id: registry_org | |
run: | | |
ORG=$(echo "${{ env.DOCKER_ORG }}" | tr '[:upper:]' '[:lower:]') | |
echo "image_base=${{ env.DOCKER_REGISTRY }}/${ORG}" >> $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@v4 | |
with: | |
images: ${{ steps.registry_org.outputs.image_base }}/${{ env.PROJECT_NAME }} | |
tags: | | |
type=raw,value=${{ matrix.CAUSTICS_VERSION }}-cuda-${{ matrix.CUDA_VERSION }} | |
- name: Log in to registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
CAUSTICS_VERSION=${{ matrix.CAUSTICS_VERSION }} | |
CUDA_VERSION=${{ matrix.CUDA_VERSION }} | |
- name: Inspect Image | |
run: | | |
docker run ${{ steps.registry_org.outputs.image_base }}/${{ env.PROJECT_NAME }}:${{ matrix.CAUSTICS_VERSION }}-cuda-${{ matrix.CUDA_VERSION }} micromamba list | |
docker images ls | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: true | |
build-args: | | |
CAUSTICS_VERSION=${{ matrix.CAUSTICS_VERSION }} | |
CUDA_VERSION=${{ matrix.CUDA_VERSION }} |