@@ -12,59 +12,45 @@ jobs:
12
12
name : Build Docker images for nginx and Zabbix
13
13
runs-on : ubuntu-latest
14
14
15
+ strategy :
16
+ matrix :
17
+ include :
18
+ - image : nginx
19
+ context : config/nginx
20
+ registry-image : ghcr.io/paskal/nginx
21
+ - image : zabbix-agent2
22
+ context : config/zabbix
23
+ registry-image : ghcr.io/paskal/zabbix-agent2
24
+
15
25
steps :
16
26
- uses : actions/checkout@v4
17
27
18
- - name : set up QEMU
28
+ - name : Set up QEMU
19
29
uses : docker/setup-qemu-action@v3
20
30
21
- - name : set up Docker Buildx
22
- id : buildx
31
+ - name : Set up Docker Buildx
23
32
uses : docker/setup-buildx-action@v3
24
33
25
- - name : available platforms
26
- run : echo ${{ steps.buildx.outputs.platforms }}
27
-
28
- - name : build nginx image without pushing (only outside master)
29
- working-directory : config/nginx
30
- if : ${{ github.ref != 'refs/heads/master' }}
31
- run : |
32
- docker buildx build \
33
- --platform linux/amd64 .
34
-
35
- - name : build Zabbix agent image without pushing (only outside master)
36
- working-directory : config/zabbix
37
- if : ${{ github.ref != 'refs/heads/master' }}
38
- run : |
39
- docker buildx build \
40
- --platform linux/amd64 .
41
-
42
- - name : build nginx image for ghcr.io
43
- working-directory : config/nginx
44
- if : ${{ github.ref == 'refs/heads/master' }}
45
- env :
46
- GITHUB_PACKAGE_TOKEN : ${{ secrets.GITHUB_TOKEN }}
47
- USERNAME : ${{ github.actor }}
48
- run : |
49
- echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
50
- docker buildx build --push \
51
- --platform linux/amd64,linux/arm64 \
52
- -t ghcr.io/paskal/nginx:latest .
53
-
54
- - name : build Zabbix agent image for ghcr.io
55
- working-directory : config/zabbix
56
- if : ${{ github.ref == 'refs/heads/master' }}
57
- env :
58
- GITHUB_PACKAGE_TOKEN : ${{ secrets.GITHUB_TOKEN }}
59
- USERNAME : ${{ github.actor }}
60
- run : |
61
- echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
62
- docker buildx build --push \
63
- --platform linux/amd64,linux/arm64 \
64
- -t ghcr.io/paskal/zabbix-agent2:latest .
65
-
66
- - name : remote update of zabbix agent after rebuild
67
- if : ${{ github.ref == 'refs/heads/master' }}
34
+ - name : Log in to GitHub Container Registry
35
+ if : github.event_name != 'pull_request'
36
+ uses : docker/login-action@v3
37
+ with :
38
+ registry : ghcr.io
39
+ username : ${{ github.actor }}
40
+ password : ${{ secrets.GITHUB_TOKEN }}
41
+
42
+ - name : Build and push ${{ matrix.image }} image
43
+ uses : docker/build-push-action@v5
44
+ with :
45
+ context : ${{ matrix.context }}
46
+ platforms : linux/amd64,linux/arm64
47
+ push : ${{ github.event_name != 'pull_request' }}
48
+ tags : ${{ matrix.registry-image }}:latest
49
+ cache-from : type=gha
50
+ cache-to : type=gha,mode=max
51
+
52
+ - name : Remote update of zabbix agent after rebuild
53
+ if : ${{ github.event_name != 'pull_request' && matrix.image == 'zabbix-agent2' }}
68
54
env :
69
55
UPDATER_KEY : ${{ secrets.UPDATER_KEY }}
70
56
run : curl -s https://hooks.favor-group.ru/update/zabbix/${UPDATER_KEY}
0 commit comments