-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (140 loc) · 5.2 KB
/
ci.yaml
File metadata and controls
164 lines (140 loc) · 5.2 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "Continuous Integration"
on:
pull_request:
push:
branches:
- "main"
- "renovate/*"
schedule:
- cron: "0 0 * * 0"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository }}
permissions:
contents: read
packages: write
jobs:
build:
name: Build per-arch (push by digest on main)
strategy:
fail-fast: false
matrix:
platform:
- platform: linux/amd64
runner: ubuntu-24.04
id: linux-amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
id: linux-arm64
version: [ "8.1", "8.2", "8.3", "8.4", "8.5" ]
extensions:
- "pcntl xdebug zip intl bcmath rdkafka pdo_pgsql pdo_mysql gd opentelemetry mongodb"
runs-on: ${{ matrix.platform.runner }}
steps:
- name: Check out the repo
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
if: ${{ github.ref_name == 'main' }}
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.version }}
- name: Build (no push)
if: ${{ github.ref_name != 'main' }}
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ matrix.platform.platform }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=ci-${{ matrix.version }}-${{ matrix.platform.id }}
type=gha,scope=release-${{ matrix.version }}-${{ matrix.platform.id }}
cache-to: |
type=gha,mode=max,scope=ci-${{ matrix.version }}-${{ matrix.platform.id }}
push: false
build-args: |
VERSION=${{ matrix.version }}
EXTENSIONS=${{ matrix.extensions }}
- name: Build and push (main only)
id: build_push
if: ${{ github.ref_name == 'main' }}
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ matrix.platform.platform }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=gha,scope=ci-${{ matrix.version }}-${{ matrix.platform.id }}
type=gha,scope=release-${{ matrix.version }}-${{ matrix.platform.id }}
cache-to: |
type=gha,mode=max,scope=release-${{ matrix.version }}-${{ matrix.platform.id }}
outputs: |
type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
build-args: |
VERSION=${{ matrix.version }}
EXTENSIONS=${{ matrix.extensions }}
- name: Store digest (main only)
if: ${{ github.ref_name == 'main' }}
run: |
mkdir -p /tmp/digests
echo "${{ steps.build_push.outputs.digest }}" > "/tmp/digests/${{ matrix.version }}-${{ matrix.platform.id }}.txt"
- name: Upload digests (main only)
if: ${{ github.ref_name == 'main' }}
uses: actions/upload-artifact@v7
with:
name: digests-${{ matrix.version }}-${{ matrix.platform.id }}
path: /tmp/digests/${{ matrix.version }}-${{ matrix.platform.id }}.txt
if-no-files-found: error
retention-days: 1
merge:
name: Create multi-arch manifest (main only)
if: ${{ github.ref_name == 'main' }}
needs: build
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
version: [ "8.1", "8.2", "8.3", "8.4", "8.5" ]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download digests (amd64)
uses: actions/download-artifact@v8
with:
name: digests-${{ matrix.version }}-linux-amd64
path: /tmp/digests
- name: Download digests (arm64)
uses: actions/download-artifact@v8
with:
name: digests-${{ matrix.version }}-linux-arm64
path: /tmp/digests
- name: Create and push manifest list tag
run: |
set -euo pipefail
AMD_DIGEST="$(cat /tmp/digests/${{ matrix.version }}-linux-amd64.txt)"
ARM_DIGEST="$(cat /tmp/digests/${{ matrix.version }}-linux-arm64.txt)"
# Create a multi-arch manifest for :<version> that points to both per-arch digests
docker buildx imagetools create \
-t "${{ env.IMAGE_NAME }}:${{ matrix.version }}" \
"${{ env.IMAGE_NAME }}@${AMD_DIGEST}" \
"${{ env.IMAGE_NAME }}@${ARM_DIGEST}"
- name: Inspect manifest (debug)
run: |
docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:${{ matrix.version }}"