forked from envoyproxy/envoy-build-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (105 loc) · 3.65 KB
/
_build_image.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
name: Build image
permissions:
contents: read
on:
workflow_call:
secrets:
dockerhub_username:
dockerhub_password:
gcp_key:
inputs:
image_prefix:
type: string
default: envoyproxy/envoy-build-
os_family:
type: string
default: linux
distro:
type: string
required: true
test_toolchain:
type: boolean
default: false
host_platform:
type: string
default: ubuntu-22.04
go_version:
type: string
default: '1.16'
gcr_push:
type: boolean
default: false
gcr_name:
type: string
default:
jobs:
image:
runs-on: ${{ inputs.host_platform }}
name: Build and test Docker image
steps:
- uses: envoyproxy/toolshed/gh-actions/[email protected]
name: 'Free disk space'
if: ${{ inputs.os_family != 'windows' }}
- name: 'Checkout repository'
uses: actions/checkout@v3
- run: |
CONTAINER_TAG=$(git log -1 --pretty=format:"%H" "./docker")
echo "tag=${CONTAINER_TAG}" >> "$GITHUB_OUTPUT"
id: container
shell: bash
name: Container hash
- run: |
curl -fsSL --output "$TEMP/gcloud-sdk.zip" "$GCLOUD_SDK_ARCHIVE_URL"
echo "${GCLOUD_SDK_ARCHIVE_CHECKSUM} $TEMP/gcloud-sdk.zip" | sha256sum --check
unzip -q "$TEMP/gcloud-sdk.zip" -d "$PROGRAMFILES"
name: Install gcloud (Windows)
shell: bash
if: ${{ inputs.os_family == 'windows' }}
env:
GCLOUD_SDK_ARCHIVE_URL: https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-289.0.0-windows-x86_64.zip
GCLOUD_SDK_ARCHIVE_CHECKSUM: c81e80040f7f609dbc50c42cd0cd402988a5c47f467372d40b5aaca0733f46f4
- run: |
if [[ "${{inputs.os_family }}" == "windows" ]]; then
export PATH="${PROGRAMFILES}/google-cloud-sdk/bin:${PATH}"
fi
cd docker
./push.sh
name: Build (${{ inputs.image_prefix }}${{ inputs.distro }}@${{ steps.container.outputs.tag }})
shell: bash
env:
OS_FAMILY: ${{ inputs.os_family }}
SOURCE_BRANCH: ${{ github.ref }}
DOCKERHUB_USERNAME: ${{ secrets.dockerhub_username }}
DOCKERHUB_PASSWORD: ${{ secrets.dockerhub_password }}
GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.gcp_key }}
IMAGE_PREFIX: ${{ inputs.image_prefix }}
OS_DISTRO: ${{ inputs.distro }}
PUSH_GCR_IMAGE: ${{ inputs.gcr_push }}
GCR_IMAGE_NAME: ${{ inputs.gcr_name }}
- name: Set up Go
uses: actions/setup-go@v4
if: ${{ inputs.test_toolchain }}
with:
go-version: ${{ inputs.go_version }}
cache: false
- uses: envoyproxy/toolshed/gh-actions/docker/[email protected]
if: ${{ inputs.test_toolchain && inputs.os_family != 'windows' }}
name: 'Start and load Docker registry'
with:
load: envoyproxy/envoy-build-ubuntu:${{ steps.container.outputs.tag }}-amd64
as: envoy-build-ubuntu:${{ steps.container.outputs.tag }}
- uses: envoyproxy/toolshed/gh-actions/docker/[email protected]
if: ${{ inputs.test_toolchain && inputs.os_family == 'windows' }}
name: 'Start and load Docker registry (Windows)'
with:
image: stefanscherer/registry-windows:2.6.2
load: envoyproxy/envoy-build-windows2019:${{ steps.container.outputs.tag }}
- run: |
toolchains/regenerate.sh
if: ${{ inputs.test_toolchain }}
shell: bash
env:
OS_FAMILY: ${{ inputs.os_family }}
SOURCE_BRANCH: ${{ github.ref }}
NO_PULL_IMAGE: true
DOCKER_IMAGE: localhost:5000/envoy-build-${{ inputs.distro }}