-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
100 lines (90 loc) · 3.52 KB
/
Copy pathaction.yaml
File metadata and controls
100 lines (90 loc) · 3.52 KB
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
---
name: Build Container Image
description: This action builds a container image with a specific version
inputs:
image-name:
description: |
The local name of the built image, for example: `kafka` or
`csi-provisioner`
required: true
image-index-manifest-tag:
description: |
Human-readable tag (usually the version) without architecture information,
for example: `3.4.1-stackable0.0.0-dev`
container-file:
description: Path to Containerfile (or Dockerfile)
default: Dockerfile
build-context:
description: Path to the build-context
default: .
build-arguments:
description: |
A comma-separated list of KEY=VALUE pairs provided as build arguments.
MUST not contain any whitespace.
outputs:
image-repository-uri:
description: |
The locally tagged name of the image, for example: `localhost/kafka`
value: ${{ steps.build-image.outputs.IMAGE_REPOSITORY_URI }}
image-manifest-tag:
description: |
Human-readable tag (usually the version) with architecture information,
for example: `3.4.1-stackable0.0.0-dev-amd64`
value: ${{ steps.build-image.outputs.IMAGE_MANIFEST_TAG }}
image-manifest-uri:
description: |
The full image manifest uri, for example:
localhost/kafka:3.4.1-stackable0.0.0-dev-amd64
value: ${{ steps.build-image.outputs.IMAGE_MANIFEST_URI }}
runs:
using: composite
steps:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Build ${{ inputs.image-name }}:${{ inputs.image-index-manifest-tag }}
id: build-image
env:
IMAGE_NAME: ${{ inputs.image-name }}
IMAGE_INDEX_MANIFEST_TAG: ${{ inputs.image-index-manifest-tag }}
CONTAINER_FILE: ${{ inputs.container-file }}
BUILD_CONTEXT: ${{ inputs.build-context }}
BUILD_ARGUMENTS: ${{ inputs.build-arguments }}
shell: bash
run: |
set -euo pipefail
# Validate that the build arguments input doesn't contain any whitespaces
if echo "$BUILD_ARGUMENTS" | grep '[[:space:]]'; then
>&2 echo "Build arguments MUST not contain any whitespace."
exit 1
fi
DOCKER_BUILD_ARGUMENTS=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_build_arguments.sh" "$BUILD_ARGUMENTS")
IMAGE_ARCH=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_architecture.sh")
IMAGE_MANIFEST_TAG="${IMAGE_INDEX_MANIFEST_TAG}-${IMAGE_ARCH}"
echo "IMAGE_MANIFEST_TAG=${IMAGE_MANIFEST_TAG}" | tee -a "$GITHUB_OUTPUT"
IMAGE_REPOSITORY_URI="localhost/${IMAGE_NAME}"
echo "IMAGE_REPOSITORY_URI=${IMAGE_REPOSITORY_URI}" | tee -a "$GITHUB_OUTPUT"
IMAGE_MANIFEST_URI="${IMAGE_REPOSITORY_URI}:${IMAGE_MANIFEST_TAG}"
echo "IMAGE_MANIFEST_URI=${IMAGE_MANIFEST_URI}" | tee -a "$GITHUB_OUTPUT"
echo "::group::docker buildx build"
# TODO (@NickLarsenNZ): Allow optional buildx cache
docker buildx build \
--file "${CONTAINER_FILE}" \
--platform "linux/${IMAGE_ARCH}" \
--tag "${IMAGE_MANIFEST_URI}" \
--load \
$DOCKER_BUILD_ARGUMENTS \
"$BUILD_CONTEXT"
echo "::endgroup::"
echo "::group::docker images"
docker images
echo "::endgroup::"
- name: Print out Disk Usage
if: always()
shell: bash
run: |
echo "::group::Disk usage after build"
echo "In GiB:"
df -h -BGiB /
echo "In MiB:"
df -h -BMiB /
echo "::endgroup::"