@@ -8,86 +8,39 @@ on: # yamllint disable-line rule:truthy
8
8
name : 🚀 Build docker images with release tag
9
9
10
10
jobs :
11
- build :
11
+ # https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/expressions#example-returning-a-json-object
12
+ prepare :
12
13
runs-on : " ubuntu-latest"
13
- strategy :
14
- fail-fast : true
15
- matrix :
16
- os_name : ["alpine"]
17
- php_version : [ "8.1" ]
18
- php_type : [ "fpm" ]
19
- # php_version: ["8.1", "8.2"]
20
- # php_type: ["fpm", "cli", "supervisord"]
21
- environment :
22
- name : release
23
- url : https://hub.docker.com/r/wayofdev/php-base/tags?page=1
24
-
14
+ outputs :
15
+ matrix : ${{ steps.matrix.outputs.matrix }}
25
16
steps :
26
- - name : 📦 Check out the codebase
27
- uses : actions/checkout@v3
28
-
29
- - name : 🛠️ Install goss and dgoss
30
-
31
-
32
- - name : 🌎 Set environment variables
33
- env :
34
- IMAGE_NAMESPACE : wayofdev/php-base
35
- IMAGE_TEMPLATE : ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
36
- IMAGE_TAG : wayofdev/php-base:${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ env.VERSION }}
17
+ - name : ⚙️ Generate matrix
18
+ id : matrix
37
19
run : |
38
- export RELEASE_VERSION="${GITHUB_REF#refs/*/}" \
39
- && { \
40
- echo "IMAGE_NAMESPACE=${IMAGE_NAMESPACE}"; \
41
- echo "IMAGE_TEMPLATE=${IMAGE_TEMPLATE}"; \
42
- echo "VERSION=${RELEASE_VERSION:1}"; \
43
- } >> "$GITHUB_ENV"
44
-
45
- - name : 🤖 Generate dist files
46
- run : make generate
47
-
48
- - name : 🐳 Extract docker meta data
49
- id : meta
50
- uses : docker/metadata-action@v4
51
- with :
52
- images : ${{ env.IMAGE_NAMESPACE }}
53
- tags : |
54
- type=raw,event=branch,value=latest
55
- type=ref,event=pr
56
- type=semver,pattern={{version}}
57
- type=semver,pattern={{major}}.{{minor}}
58
- flavor : |
59
- latest=false
60
- prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-
61
-
62
- - name : 🔑 Login to docker-hub
63
- if : github.event_name != 'pull_request'
64
- uses : docker/login-action@v2
65
- with :
66
- username : ${{ secrets.DOCKER_USERNAME }}
67
- password : ${{ secrets.DOCKER_TOKEN }}
68
-
69
- - name : 🖥️ Setup QEMU
70
- uses : docker/setup-qemu-action@v2
71
- with :
72
- platforms : arm64
73
-
74
- - name : 🛠️ Setup docker Buildx
75
- uses : docker/setup-buildx-action@v2
76
- with :
77
- install : true
78
-
79
- - name : 🚀 Build image and push to docker-hub
80
- uses : docker/build-push-action@v4
81
- with :
82
- context : ./dist/base/${{ env.IMAGE_TEMPLATE }}
83
- platforms : linux/amd64,linux/arm64
84
- push : ${{ github.event_name != 'pull_request' }}
85
- tags : ${{ steps.meta.outputs.tags }}
86
- cache-from : type=gha
87
- cache-to : type=gha,mode=max
88
- labels : ${{ steps.meta.outputs.labels }}
20
+ echo 'matrix={
21
+ "os_name": ["alpine"],
22
+ "php_version": ["8.1", "8.2"],
23
+ "php_type": ["fpm", "cli", "supervisord"]
24
+ }' | tr -d '\n' >> $GITHUB_OUTPUT
25
+
26
+ - name : ⚙️ Get version for image tag
27
+ id : version
28
+ run : |
29
+ echo "version=$(echo ${GITHUB_REF#refs/*/} | cut -c 2-)" >> $GITHUB_OUTPUT
89
30
90
- - name : 🧪 Test Docker image with "version" tag
91
- run : IMAGE_TAG=${{ env.IMAGE_TAG }} make test
31
+ build :
32
+ needs : prepare
33
+ strategy :
34
+ matrix : ${{ fromJson(needs.prepare.outputs.matrix )}}
35
+ uses : wayofdev/gh-actions/.github/workflows/build-image.yml@master
36
+ with :
37
+ os : " ubuntu-latest"
38
+ push-to-hub : true
39
+ image-namespace : " wayofdev/php-base"
40
+ image-template : ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
41
+ image-version : ${{ needs.prepare.outputs.version }}
42
+ secrets :
43
+ docker-username : ${{ secrets.DOCKER_USERNAME }}
44
+ docker-password : ${{ secrets.DOCKER_TOKEN }}
92
45
93
46
...
0 commit comments