-
Notifications
You must be signed in to change notification settings - Fork 1.6k
156 lines (141 loc) · 4.96 KB
/
build-legacy-branch.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
145
146
147
148
149
150
151
152
153
154
155
156
name: Build containers for a specific branch of 1.8
on:
workflow_dispatch:
inputs:
ref:
description: The code to build so a commit, branch, etc. The container image will be ghcr.io/fluent/fluent-bit/test/<this value>.
required: true
default: "1.8"
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}/test/${{ github.event.inputs.ref }}
jobs:
build-legacy-branch-meta:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Check this is a 1.8 type build
run: |
if [[ -f "dockerfiles/Dockerfile" ]]; then
echo "Invalid branch as contains Dockerfile: ${{ inputs.ref }}"
exit 1
fi
shell: bash
# For 1.8 builds it is a little more complex so we have this build matrix to handle it.
# This creates separate images for each architecture.
# The later step then creates a multi-arch manifest for all of these.
build-legacy-images-matrix:
name: Build single arch legacy images
runs-on: ubuntu-latest
needs:
- build-legacy-branch-meta
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64, arm/v7]
include:
- arch: amd64
suffix: x86_64
- arch: arm/v7
suffix: arm32v7
- arch: arm64
suffix: arm64v8
permissions:
contents: read
packages: write
steps:
- name: Checkout the docker build repo for legacy builds
uses: actions/checkout@v4
with:
repository: fluent/fluent-bit-docker-image
ref: "1.8" # Fixed to this branch
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: debug-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
raw,${{ inputs.ref }}-debug
- name: Build the legacy x86_64 debug image
if: matrix.arch == 'amd64'
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.x86_64.debug
context: .
tags: ${{ steps.debug-meta.outputs.tags }}
labels: ${{ steps.debug-meta.outputs.labels }}
provenance: false
platforms: linux/amd64
push: true
load: false
build-args: |
FLB_TARBALL=https://github.com/fluent/fluent-bit/tarball/${{ inputs.ref }}
- name: Extract metadata from Github
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
raw,${{ matrix.suffix }}-${{ inputs.ref }}
- name: Build the legacy ${{ matrix.arch }} image
uses: docker/build-push-action@v6
with:
file: ./Dockerfile.${{ matrix.suffix }}
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/${{ matrix.arch }}
provenance: false
push: true
load: false
build-args: |
FLB_TARBALL=https://github.com/fluent/fluent-bit/tarball/${{ inputs.ref }}
# Create a multi-arch manifest for the separate 1.8 images.
build-legacy-image-manifests:
name: Deploy multi-arch container image manifests
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
needs:
- build-legacy-branch-meta
- build-legacy-images-matrix
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull all the images
# Use platform to trigger warnings on invalid image metadata
run: |
docker pull --platform=linux/amd64 ${{ env.IMAGE_NAME }}:x86_64-${{ inputs.ref }}
docker pull --platform=linux/arm64 ${{ env.IMAGE_NAME }}:arm64v8-${{ inputs.ref }}
docker pull --platform=linux/arm/v7 ${{ env.IMAGE_NAME }}:arm32v7-${{ inputs.ref }}
shell: bash
- name: Create manifests for images
run: |
docker manifest create ${{ env.IMAGE_NAME }}:${{ inputs.ref }} \
--amend ${{ env.IMAGE_NAME }}:x86_64-${{ inputs.ref }} \
--amend ${{ env.IMAGE_NAME }}:arm64v8-${{ inputs.ref }} \
--amend ${{ env.IMAGE_NAME }}:arm32v7-${{ inputs.ref }}
docker manifest push --purge ${{ env.IMAGE_NAME }}:${{ inputs.ref }}
env:
DOCKER_CLI_EXPERIMENTAL: enabled
shell: bash