11
11
- v*.*.*
12
12
workflow_dispatch :
13
13
inputs : {}
14
+ schedule :
15
+ - cron : ' 0 4 * * *'
14
16
jobs :
15
17
prepare :
16
18
runs-on : ubuntu-latest
17
19
outputs :
18
- # Push only if it's a tag or if we're committing in the main branch
19
- push : ${{ toJson(startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')) }}
20
+ # Push if it's a scheduled job, a tag, or if we're committing to the main branch
21
+ push : ${{ toJson(github.event_name == 'schedule' || startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')) }}
20
22
variants : ${{ steps.matrix.outputs.variants }}
21
23
platforms : ${{ steps.matrix.outputs.platforms }}
22
24
metadata : ${{ steps.matrix.outputs.metadata }}
23
- php_version : ${{ steps.matrix.outputs.php_version }}
25
+ php_version : ${{ steps.check.outputs.php_version }}
26
+ skip : ${{ steps.check.outputs.skip }}
27
+ ref : ${{ steps.check.outputs.ref }}
24
28
steps :
29
+ -
30
+ name : Check PHP versions
31
+ id : check
32
+ run : |
33
+ PHP_82_LATEST=$(skopeo inspect docker://docker.io/library/php:8.2 --override-os linux --override-arch amd64 | jq -r '.Env[] | select(test("^PHP_VERSION=")) | sub("^PHP_VERSION="; "")')
34
+ PHP_83_LATEST=$(skopeo inspect docker://docker.io/library/php:8.3 --override-os linux --override-arch amd64 | jq -r '.Env[] | select(test("^PHP_VERSION=")) | sub("^PHP_VERSION="; "")')
35
+ echo php_version="${PHP_83_LATEST},${PHP_82_LATEST}" >> "${GITHUB_OUTPUT}"
36
+
37
+ # Check if the Docker images must be rebuilt
38
+ if [[ "${GITHUB_EVENT_NAME}" != "schedule" ]]; then
39
+ echo skip=false >> "${GITHUB_OUTPUT}"
40
+ exit 0
41
+ fi
42
+
43
+ FRANKENPHP_82_LATEST=$(skopeo inspect docker://docker.io/dunglas/frankenphp:latest-php8.2 --override-os linux --override-arch amd64 | jq -r '.Env[] | select(test("^PHP_VERSION=")) | sub("^PHP_VERSION="; "")')
44
+ FRANKENPHP_83_LATEST=$(skopeo inspect docker://docker.io/dunglas/frankenphp:latest-php8.3 --override-os linux --override-arch amd64 | jq -r '.Env[] | select(test("^PHP_VERSION=")) | sub("^PHP_VERSION="; "")')
45
+
46
+ if [[ "${FRANKENPHP_82_LATEST}" == "${PHP_82_LATEST}" ]] && [[ "${FRANKENPHP_83_LATEST}" == "${PHP_83_LATEST}" ]]; then
47
+ echo skip=true >> "${GITHUB_OUTPUT}"
48
+ exit 0
49
+ fi
50
+
51
+ {
52
+ echo ref="$(gh release view --repo dunglas/frankenphp --json tagName --jq '.tagName')"
53
+ echo skip=false
54
+ } >> "${GITHUB_OUTPUT}"
25
55
-
26
56
uses : actions/checkout@v4
57
+ if : ${{ !fromJson(steps.check.outputs.skip) }}
58
+ with :
59
+ ref : ${{ steps.check.outputs.ref }}
27
60
-
28
61
name : Set up Docker Buildx
29
62
uses : docker/setup-buildx-action@v3
30
63
with :
31
64
version : latest
32
65
-
33
66
name : Create variants matrix
67
+ if : ${{ !fromJson(steps.check.outputs.skip) }}
34
68
id : matrix
35
69
run : |
36
- # Fetch latest versions of PHP
37
- PHP_82_LATEST=$(skopeo inspect docker://docker.io/library/php:8.2 --override-os linux --override-arch amd64 | jq -r '.Env[] | select(test("^PHP_VERSION=")) | sub("^PHP_VERSION="; "")')
38
- PHP_83_LATEST=$(skopeo inspect docker://docker.io/library/php:8.3 --override-os linux --override-arch amd64 | jq -r '.Env[] | select(test("^PHP_VERSION=")) | sub("^PHP_VERSION="; "")')
39
- export PHP_VERSION="${PHP_83_LATEST},${PHP_82_LATEST}"
40
-
41
70
METADATA="$(docker buildx bake --print | jq -c)"
42
-
43
71
{
44
- echo php_version="$PHP_VERSION"
45
- echo metadata="$METADATA"
46
- echo variants="$(jq -c '.group.default.targets|map(sub("runner-|builder-"; ""))|unique' <<< "$METADATA")"
47
- echo platforms="$(jq -c 'first(.target[]) | .platforms' <<< "$METADATA")"
48
- } >> "$GITHUB_OUTPUT"
72
+ echo metadata="${METADATA}"
73
+ echo variants="$(jq -c '.group.default.targets|map(sub("runner-|builder-"; ""))|unique' <<< "${METADATA}")"
74
+ echo platforms="$(jq -c 'first(.target[]) | .platforms' <<< "${METADATA}")"
75
+ } >> "${GITHUB_OUTPUT}"
49
76
env :
50
77
SHA : ${{ github.sha }}
51
- VERSION : ${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
78
+ VERSION : ${{ (github.ref_type == 'tag' && github.ref_name) || steps.check.outputs.ref || github.sha }}
79
+ PHP_VERSION : ${{ steps.check.outputs.php_version }}
52
80
build :
53
81
runs-on : ubuntu-latest
54
82
needs :
55
83
- prepare
84
+ if : ${{ !fromJson(needs.prepare.outputs.skip) }}
56
85
strategy :
57
86
fail-fast : false
58
87
matrix :
69
98
steps :
70
99
-
71
100
uses : actions/checkout@v4
101
+ with :
102
+ ref : ${{ needs.prepare.outputs.ref }}
72
103
-
73
104
name : Set up QEMU
74
105
if : matrix.qemu
@@ -108,7 +139,7 @@ jobs:
108
139
${{ fromJson(needs.prepare.outputs.push) && '*.output=type=image,name=dunglas/frankenphp,push-by-digest=true,name-canonical=true,push=true' || '' }}
109
140
env :
110
141
SHA : ${{ github.sha }}
111
- VERSION : ${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
142
+ VERSION : ${{ github.ref_type == 'tag' && github.ref_name || needs.prepare.outputs.ref || github.sha }}
112
143
PHP_VERSION : ${{ needs.prepare.outputs.php_version }}
113
144
-
114
145
# Workaround for https://github.com/actions/runner/pull/2477#issuecomment-1501003600
@@ -118,11 +149,11 @@ jobs:
118
149
mkdir -p /tmp/metadata/builder /tmp/metadata/runner
119
150
120
151
# shellcheck disable=SC2086
121
- builderDigest=$(jq -r '."builder-${{ matrix.variant }}"."containerimage.digest"' <<< $METADATA)
152
+ builderDigest=$(jq -r '."builder-${{ matrix.variant }}"."containerimage.digest"' <<< ${ METADATA} )
122
153
touch "/tmp/metadata/builder/${builderDigest#sha256:}"
123
154
124
155
# shellcheck disable=SC2086
125
- runnerDigest=$(jq -r '."runner-${{ matrix.variant }}"."containerimage.digest"' <<< $METADATA)
156
+ runnerDigest=$(jq -r '."runner-${{ matrix.variant }}"."containerimage.digest"' <<< ${ METADATA} )
126
157
touch "/tmp/metadata/runner/${runnerDigest#sha256:}"
127
158
env :
128
159
METADATA : ${{ steps.build.outputs.metadata }}
@@ -150,7 +181,7 @@ jobs:
150
181
continue-on-error : ${{ fromJson(needs.prepare.outputs.push) }}
151
182
run : |
152
183
docker run --platform=${{ matrix.platform }} --rm \
153
- "$(jq -r '."builder-${{ matrix.variant }}"."containerimage.config.digest"' <<< "$METADATA")" \
184
+ "$(jq -r '."builder-${{ matrix.variant }}"."containerimage.config.digest"' <<< "${ METADATA} ")" \
154
185
sh -c 'go test ${{ matrix.race }} -v ./... && cd caddy && go test ${{ matrix.race }} -v ./...'
155
186
env :
156
187
METADATA : ${{ steps.build.outputs.metadata }}
@@ -189,14 +220,14 @@ jobs:
189
220
working-directory : /tmp/metadata
190
221
run : |
191
222
# shellcheck disable=SC2046,SC2086
192
- docker buildx imagetools create $(jq -cr '.target."${{ matrix.target }}-${{ matrix.variant }}".tags | map("-t " + .) | join(" ")' <<< $METADATA) \
223
+ docker buildx imagetools create $(jq -cr '.target."${{ matrix.target }}-${{ matrix.variant }}".tags | map("-t " + .) | join(" ")' <<< ${ METADATA} ) \
193
224
$(printf 'dunglas/frankenphp@sha256:%s ' *)
194
225
env :
195
226
METADATA : ${{ needs.prepare.outputs.metadata }}
196
227
-
197
228
name : Inspect image
198
229
run : |
199
230
# shellcheck disable=SC2046,SC2086
200
- docker buildx imagetools inspect $(jq -cr '.target."${{ matrix.target }}-${{ matrix.variant }}".tags | first' <<< $METADATA)
231
+ docker buildx imagetools inspect $(jq -cr '.target."${{ matrix.target }}-${{ matrix.variant }}".tags | first' <<< ${ METADATA} )
201
232
env :
202
233
METADATA : ${{ needs.prepare.outputs.metadata }}
0 commit comments