forked from Ciela-Institute/caustics
-
Notifications
You must be signed in to change notification settings - Fork 4
117 lines (104 loc) · 3.51 KB
/
image_ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Docker Build
on:
push:
branches:
- main
- dev
paths:
- "src/**"
- "tests/**"
- "resources/docker/Dockerfile"
- "resources/docker/*.lock"
- "resources/docker/*.yaml"
- "resources/docker/*.sh"
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@v3
- 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@v4
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@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: .
file: ./resources/docker/Dockerfile
platforms: linux/amd64
load: ${{ env.GITHUB_REF != 'refs/heads/main' }}
push: ${{ env.GITHUB_REF == 'refs/heads/main' }}
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