-
Notifications
You must be signed in to change notification settings - Fork 39
148 lines (130 loc) · 5.12 KB
/
Copy pathbigquery-emulator-build.yaml
File metadata and controls
148 lines (130 loc) · 5.12 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
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
name: Build and Push BigQuery Emulator Multi-Arch Image
on:
push:
branches:
- main
paths:
- 'tools/bigquery-emulator/**'
workflow_dispatch:
inputs:
version:
description: "BigQuery emulator version (leave empty to use Dockerfile default)"
type: string
required: false
env:
IMAGE_NAME: ghcr.io/bucketeer-io/bigquery-emulator
jobs:
# Extract version from Dockerfile
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Extract version from Dockerfile
id: get-version
run: |
# Use input version if provided, otherwise extract from Dockerfile
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=$(grep -E '^ARG VERSION=' tools/bigquery-emulator/Dockerfile | sed 's/ARG VERSION=//')
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Using version: ${VERSION}"
# Build AMD64 architecture
build-amd64:
runs-on: ubuntu-latest
needs: get-version
env:
VERSION: ${{ needs.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Setup Docker buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
with:
use: true
- name: Login to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push AMD64 image
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: ./tools/bigquery-emulator
platforms: linux/amd64
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}-amd64
build-args: |
VERSION=${{ env.VERSION }}
cache-from: type=gha,scope=bigquery-emulator-amd64
cache-to: type=gha,mode=max,scope=bigquery-emulator-amd64
provenance: false
# Build ARM64 architecture
build-arm64:
runs-on: ubuntu-latest
needs: get-version
env:
VERSION: ${{ needs.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Set up QEMU for ARM64 builds
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
with:
platforms: linux/arm64
- name: Setup Docker buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
with:
use: true
- name: Login to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ARM64 image
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: ./tools/bigquery-emulator
platforms: linux/arm64
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}-arm64
build-args: |
VERSION=${{ env.VERSION }}
cache-from: type=gha,scope=bigquery-emulator-arm64
cache-to: type=gha,mode=max,scope=bigquery-emulator-arm64
provenance: false
# Create multi-arch manifest that combines both architectures
create-manifest:
runs-on: ubuntu-latest
needs: [get-version, build-amd64, build-arm64]
env:
VERSION: ${{ needs.get-version.outputs.version }}
steps:
- name: Setup Docker buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
with:
use: true
- name: Login to GitHub Container Registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-arch manifest
run: |
# Create and push versioned manifest using buildx imagetools
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:${{ env.VERSION }} \
${{ env.IMAGE_NAME }}:${{ env.VERSION }}-amd64 \
${{ env.IMAGE_NAME }}:${{ env.VERSION }}-arm64
# Create and push latest manifest
docker buildx imagetools create -t ${{ env.IMAGE_NAME }}:latest \
${{ env.IMAGE_NAME }}:${{ env.VERSION }}-amd64 \
${{ env.IMAGE_NAME }}:${{ env.VERSION }}-arm64
echo "Multi-arch image pushed: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}"
echo "Multi-arch image pushed: ${{ env.IMAGE_NAME }}:latest"