-
Notifications
You must be signed in to change notification settings - Fork 314
103 lines (100 loc) · 4.01 KB
/
docker-build.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
name: Docker Build
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
env:
GRADLE_OPTS: -Dorg.gradle.daemon=false
REGISTRY: ghcr.io
jobs:
disk_space:
name: Docker Build
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Free Disk Space
uses: ./.github/actions/free-disk-space
- name: Setup Gradle
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4
- name: Get ORT version
run: |
ORT_VERSION=$(./gradlew -q properties --property version | sed -nr "s/version: (.+)/\1/p")
echo "ORT_VERSION=${ORT_VERSION}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Metadata for 'ort' Docker Image
id: meta-ort
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
with:
images: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/ort
tags: |
type=pep440,pattern={{version}}
type=raw,value=${{ env.ORT_VERSION }}
type=ref,event=branch
type=ref,event=tag
type=sha
- name: Build & Push 'ort' Docker Image
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6
with:
context: .
push: true
tags: ${{ steps.meta-ort.outputs.tags }}
labels: ${{ steps.meta-ort.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:cache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:cache,mode=max
build-args: ORT_VERSION=${{ env.ORT_VERSION }}
sbom: true
- name: Build 'ort' Docker Image
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6
with:
context: .
tags: ${{ steps.meta-ort.outputs.tags }}
labels: ${{ steps.meta-ort.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:cache
build-args: ORT_VERSION=${{ env.ORT_VERSION }}
sbom: true
- name: Extract Metadata for 'ort-minimal' Docker Image
id: meta-ort-minimal
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
with:
images: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-minimal
tags: |
type=pep440,pattern={{version}}
type=raw,value=${{ env.ORT_VERSION }}
type=ref,event=branch
type=ref,event=tag
type=sha
- name: Build & Push 'ort-minimal' Docker Image
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6
with:
context: .
# Do not "cache-to" here to not overwrite additional layers from the "full" image, which also contains all
# layers present in the "minimal" image anyway.
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-ort-minimal.outputs.tags }}
labels: ${{ steps.meta-ort-minimal.outputs.labels }}
target: minimal
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:cache
build-args: ORT_VERSION=${{ env.ORT_VERSION }}
sbom: true
- name: Print Disk Space
run: df -h