-
Notifications
You must be signed in to change notification settings - Fork 1.6k
144 lines (133 loc) · 4.25 KB
/
call-integration-image-build.yaml
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Reusable workflow for integration testing
on:
workflow_call:
inputs:
ref:
description: The SHA, commit or branch to checkout and build.
required: true
type: string
registry:
description: The registry to push container images to.
type: string
required: true
username:
description: The username for the registry.
type: string
required: true
image:
description: The name of the container image to push to the registry.
type: string
required: true
image-tag:
description: The tag of the image to for testing.
type: string
required: true
environment:
description: The Github environment to run this workflow on.
type: string
required: false
secrets:
token:
description: The Github token or similar to authenticate with for the registry.
required: true
jobs:
call-integration-image-build-container:
name: Integration test container image build
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ secrets.token }}
- name: Extract metadata from Github
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ inputs.registry }}/${{ inputs.image }}
tags: |
raw,${{ inputs.image-tag }}
- name: Build the AMD64 image
uses: docker/build-push-action@v4
with:
file: ./dockerfiles/Dockerfile
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
target: production
provenance: false
push: true
load: false
- name: Upload the image just in case as an artefact
run: |
docker pull $IMAGE
docker save --output /tmp/pr-image.tar $IMAGE
env:
IMAGE: ${{ steps.meta.outputs.tags }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: pr-${{ github.event.pull_request.number }}-image
path: /tmp/pr-image.tar
if-no-files-found: error
- name: Extract metadata from Github
id: meta-debug
uses: docker/metadata-action@v4
with:
images: ${{ inputs.registry }}/${{ inputs.image }}
tags: |
raw,${{ inputs.image-tag }}-debug
- name: Build the AMD64 debug image
uses: docker/build-push-action@v4
with:
file: ./dockerfiles/Dockerfile
context: .
tags: ${{ steps.meta-debug.outputs.tags }}
labels: ${{ steps.meta-debug.outputs.labels }}
provenance: false
target: debug
platforms: linux/amd64
push: true
load: false
call-integration-image-build-smoke-test:
name: Integration test image is valid
needs: call-integration-image-build-container
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ secrets.token }}
- name: Test the HTTP server is responding
timeout-minutes: 5
run: |
packaging/testing/smoke/container/container-smoke-test.sh
shell: bash
env:
CONTAINER_NAME: local-smoke-${{ inputs.image-tag }}
CONTAINER_ARCH: linux/amd64
REGISTRY: ${{ inputs.registry }}
IMAGE_NAME: ${{ inputs.image }}
IMAGE_TAG: ${{ inputs.image-tag }}