5
5
- cron : ' 24 9 * * *'
6
6
push :
7
7
branches : [ "main" ]
8
+ # Publish semver tags as releases.
8
9
tags : [ 'v*.*.*' ]
9
10
pull_request :
10
11
branches : [ "main" ]
11
12
12
13
env :
14
+ # Use docker.io for Docker Hub if empty
13
15
REGISTRY : ghcr.io
16
+ # github.repository as <account>/<repo>
14
17
IMAGE_NAME : ${{ github.repository }}
15
18
16
19
jobs :
19
22
strategy :
20
23
matrix :
21
24
php-version : [ '8.0', '8.1', '8.2', '8.3', '8.4' ] # PHP versions to build
22
- architecture : [ 'amd64', 'arm64' ] # Add architecture matrix
23
25
24
26
permissions :
25
27
contents : read
30
32
- name : Checkout repository
31
33
uses : actions/checkout@v4
32
34
33
- - name : Set up BuildKit Docker container builder
35
+ # Install the cosign tool except on PR
36
+ - name : Install cosign
37
+ if : github.event_name != 'pull_request'
38
+ uses : sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
39
+ with :
40
+ cosign-release : ' v2.2.4'
41
+
42
+ # Set up BuildKit Docker container builder
43
+ - name : Set up Docker Buildx
34
44
uses : docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
35
45
46
+ # Login against a Docker registry except on PR
36
47
- name : Log into registry ${{ env.REGISTRY }}
37
48
if : github.event_name != 'pull_request'
38
49
uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
41
52
username : ${{ github.actor }}
42
53
password : ${{ secrets.GITHUB_TOKEN }}
43
54
55
+ # Extract metadata (tags, labels) for Docker
44
56
- name : Extract Docker metadata
45
57
id : meta
46
58
uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
50
62
${{ matrix.php-version }}-${{ github.sha }}
51
63
${{ matrix.php-version }}-latest
52
64
${{ matrix.php-version }}
53
-
65
+
66
+ # Build and push Docker image with Buildx (don't push on PR)
54
67
- name : Build and push Docker image
55
68
id : build-and-push
56
69
uses : docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
@@ -64,11 +77,11 @@ jobs:
64
77
cache-to : type=gha,mode=max
65
78
build-args : |
66
79
PHP_VERSION=${{ matrix.php-version }}
67
- ARCH=${{ matrix.architecture }} # Pass architecture to Dockerfile
68
80
81
+ # Sign the resulting Docker image digest except on PRs.
69
82
- name : Sign the published Docker image
70
83
if : ${{ github.event_name != 'pull_request' }}
71
84
env :
72
85
TAGS : ${{ steps.meta.outputs.tags }}
73
86
DIGEST : ${{ steps.build-and-push.outputs.digest }}
74
- run : echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
87
+ run : echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
0 commit comments