ci: Update to push image and not worry about inspecting on push to main #19
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 | |
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: | |
name: ${{ matrix.CAUSTICS_VERSION }}-cuda-${{ matrix.CUDA_VERSION }} | |
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: . | |
platforms: linux/amd64 | |
load: true | |
push: ${{ github.ref == 'refs/heads/main' }} | |
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 |