Skip to content

Commit 876e140

Browse files
committed
ubuntu/image: Upload as artefact in PRs
Signed-off-by: Ryan Northey <[email protected]>
1 parent cd68397 commit 876e140

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

.github/workflows/_build_image.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ on:
2525
test_toolchain:
2626
type: boolean
2727
default: false
28+
upload_ubuntu_image:
29+
type: boolean
30+
default: false
2831

2932
host_platform:
3033
type: string
@@ -51,6 +54,9 @@ jobs:
5154
if: ${{ inputs.os_family != 'windows' }}
5255
- name: 'Checkout repository'
5356
uses: actions/checkout@v3
57+
- uses: envoyproxy/toolshed/gh-actions/docker/[email protected]
58+
if: ${{ (inputs.test_toolchain || inputs.upload_ubuntu_image) && inputs.os_family != 'windows' }}
59+
name: 'Start Docker registry'
5460
- run: |
5561
CONTAINER_TAG=$(git log -1 --pretty=format:"%H" "./docker")
5662
echo "tag=${CONTAINER_TAG}" >> "$GITHUB_OUTPUT"
@@ -92,11 +98,6 @@ jobs:
9298
with:
9399
go-version: ${{ inputs.go_version }}
94100
cache: false
95-
- uses: envoyproxy/toolshed/gh-actions/docker/[email protected]
96-
if: ${{ inputs.test_toolchain && inputs.os_family != 'windows' }}
97-
name: 'Start and load Docker registry'
98-
with:
99-
load: envoyproxy/envoy-build-ubuntu:${{ steps.container.outputs.tag }}
100101
- uses: envoyproxy/toolshed/gh-actions/docker/[email protected]
101102
if: ${{ inputs.test_toolchain && inputs.os_family == 'windows' }}
102103
name: 'Start and load Docker registry (Windows)'
@@ -112,3 +113,15 @@ jobs:
112113
SOURCE_BRANCH: ${{ github.ref }}
113114
NO_PULL_IMAGE: true
114115
DOCKER_IMAGE: localhost:5000/envoy-build-${{ inputs.distro }}
116+
- run: |
117+
sudo mkdir -p /mnt/cache
118+
sudo mount -t tmpfs none /mnt/cache
119+
docker save envoyproxy/envoy-build-ubuntu:${{ steps.container.outputs.tag }}-multi \
120+
| zstd - -q -T0 -o /mnt/cache/envoy-build-ubuntu-${{ steps.container.outputs.tag }}.tar.zst
121+
if: ${{ inputs.upload_ubuntu_image }}
122+
shell: bash
123+
- uses: actions/upload-artifact@v3
124+
if: ${{ inputs.upload_ubuntu_image }}
125+
with:
126+
name: envoy-build-ubuntu-${{ steps.container.outputs.tag }}
127+
path: /mnt/cache/envoy-build-ubuntu-${{ steps.container.outputs.tag }}.tar.zst

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
os_family: ${{ matrix.os_family != '' && matrix.os_family || 'linux' }}
4747
host_platform: ${{ matrix.host_platform != '' && matrix.host_platform || 'ubuntu-22.04' }}
4848
test_toolchain: ${{ github.event_name == 'pull_request' && matrix.target != 'centos' }}
49+
upload_ubuntu_image: ${{ github.event_name == 'pull_request' && matrix.target == 'ubuntu' }}
4950
secrets:
5051
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
5152
dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }}

docker/linux/build.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,19 @@ if [[ -n "${IMAGE_TAGS}" ]]; then
7070
fi
7171

7272
if [[ "$LOAD_IMAGE" == "true" ]]; then
73-
# Testing after push to save CI time because this invalidates arm64 cache
74-
ci_log_run docker buildx build . -f "${OS_DISTRO}/Dockerfile" -t "${IMAGE_NAME}:${CONTAINER_TAG}" --platform "linux/amd64" --load
73+
ci_log_run docker buildx build . \
74+
--push \
75+
-f "${OS_DISTRO}/Dockerfile" \
76+
-t "localhost:5000/${IMAGE_NAME}:${CONTAINER_TAG}" \
77+
--platform "linux/amd64"
78+
ci_log_run docker buildx build . \
79+
--push \
80+
-f "${OS_DISTRO}/Dockerfile" \
81+
-t "localhost:5000/${IMAGE_NAME}:${CONTAINER_TAG}-arm64" \
82+
--platform "linux/arm64"
83+
ci_log_run docker manifest create \
84+
envoyproxy/envoy-build-ubuntu:${{ steps.container.outputs.tag }}-multi \
85+
envoyproxy/envoy-build-ubuntu:${{ steps.container.outputs.tag }} \
86+
envoyproxy/envoy-build-ubuntu:${{ steps.container.outputs.tag }}-arm64
87+
7588
fi

0 commit comments

Comments
 (0)