-
Notifications
You must be signed in to change notification settings - Fork 138
127 lines (119 loc) · 5.82 KB
/
legacy-v5.yml
File metadata and controls
127 lines (119 loc) · 5.82 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
name: Direct build v5 of legacy php
on:
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
php_version: ['8.1', '8.0', '7.4']
variant: ['apache','cli','fpm']
builder: [ {arch: "amd64", os: "ubuntu-24.04"}, {arch: "arm64", os: "ubuntu-24.04-arm"}]
runs-on: ${{ matrix.builder.os }}
name: Build ${{ matrix.php_version }}-${{ matrix.variant }} ${{ matrix.builder.arch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker
uses: docker-practice/actions-setup-docker@master
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
run: |
PHP_VERSION="${{ matrix.php_version }}"
# Get last cached successful builds
TARGETS=$(REPO="ghcr.io/${{ github.repository_owner }}/php" TAG_PREFIX="" docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --progress=quiet --print | jq -r '.target[].tags[]')
for TARGET in $TARGETS; do
docker --quiet pull ${TARGET} || echo ""
done;
# Build the current builds
REPO="ghcr.io/${{ github.repository_owner }}/php" \
ARCH_SUFFIX="-${{ matrix.builder.arch }}" \
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
docker buildx bake \
--set "*.platform=linux/${{ matrix.builder.arch }}" \
--set "*.output=type=registry" \
--progress=quiet \
--load \
php${PHP_VERSION//.}-${{ matrix.variant }}-all
- name: Display tags built
run: |
docker image ls --filter="reference=ghcr.io/${{ github.repository_owner }}/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}"
merge-and-publish:
needs:
- build
runs-on: ubuntu-latest
name: Merge and publish ${{ matrix.php_version }}-${{ matrix.variant }}
strategy:
fail-fast: false
matrix:
php_version: ['8.1', '8.0', '7.4']
variant: ['apache','cli','fpm']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v3
if: ${{ github.repository_owner == 'thecodingmachine' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Install regctl
uses: regclient/actions/regctl-installer@main
with:
release: 'v0.8.1'
- name: Fetch minor version of php
run: |
# Pull amd64 slim image to get PHP version
docker pull --quiet ghcr.io/${{ github.repository_owner }}/php:rc${GITHUB_RUN_ID}-${{ matrix.php_version }}-v5-slim-${{ matrix.variant }}-amd64
# Retrieve minor
PHP_PATCH_MINOR=`docker run --rm ghcr.io/${{ github.repository_owner }}/php:rc${GITHUB_RUN_ID}-${{ matrix.php_version }}-v5-slim-${{ matrix.variant }}-amd64 php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}"
echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}" >> $GITHUB_ENV
- name: Get list of images for this variant
id: get-images
run: |
PHP_VERSION="${{ matrix.php_version }}"
REPO="ghcr.io/${{ github.repository_owner }}/php" \
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
docker buildx bake \
--print --progress=quiet \
php${PHP_VERSION//.}-${{ matrix.variant }}-all | jq '.target[].tags[]'
- name: Create multiarch manifests
run: |
PHP_VERSION="${{ matrix.php_version }}"
# Get all targets from the bake group
TARGETS=$(docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --progress=quiet --print | jq -r ".group[\"php${PHP_VERSION//.}-${{ matrix.variant }}-all\"].targets[]")
for TARGET in $TARGETS; do
TAG_ORI=$(REPO="ghcr.io/${{ github.repository_owner }}/php" TAG_PREFIX="rc${GITHUB_RUN_ID}-" docker buildx bake ${TARGET} --progress=quiet --print | jq -r ".target | to_entries[] | select(.key == \"${TARGET}\") | .value.tags[0]")
TAG_PATH=$(REPO="php" PHP_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" docker buildx bake ${TARGET} --progress=quiet --print | jq -r ".target | to_entries[] | select(.key == \"${TARGET}\") | .value.tags[0]")
TAG_MINOR=$(REPO="php" docker buildx bake ${TARGET} --progress=quiet --print | jq -r ".target | to_entries[] | select(.key == \"${TARGET}\") | .value.tags[0]")
# Create manifest for rc tag (always)
echo "Creating manifest: ${TARGET} - ${TAG_ORI}"
docker buildx imagetools create --progress=plain -t "${TAG_ORI}" "${TAG_ORI}-amd64" "${TAG_ORI}-arm64"
# Create manifest for PHP_PATCH
regctl image copy "${TAG_ORI}" "ghcr.io/${{ github.repository_owner }}/${TAG_PATH}"
# Create manifest for PHP_MINOR
regctl image copy "${TAG_ORI}" "ghcr.io/${{ github.repository_owner }}/${TAG_MINOR}"
# SAME FOR DOCKERHUB (for the official repository)
if [ "${{ github.repository_owner }}" == "thecodingmachine" ]; then
# Create manifest for PHP_PATCH_MINOR
regctl image copy "${TAG_ORI}" "thecodingmachine/${TAG_PATH}"
# Create manifest for PHP_VERSION
regctl image copy "${TAG_ORI}" "thecodingmachine/${TAG_MINOR}"
fi
done