1
+ name : Build and Publish (development-v6)
2
+ on :
3
+ schedule :
4
+ - cron : " 0 5 * * *"
5
+ push :
6
+ branches :
7
+ - development-v6
8
+
9
+ env :
10
+ dockerhub : ${{ secrets.DOCKERHUB_NAMESPACE }}/pihole
11
+ ghcr : ghcr.io/${{ github.repository_owner }}/pihole
12
+
13
+ jobs :
14
+ build :
15
+ runs-on : ubuntu-latest
16
+ strategy :
17
+ fail-fast : false
18
+ matrix :
19
+ platform : [linux/amd64, linux/386, linux/arm/v6, linux/arm/v7, linux/arm64]
20
+ alpine_version : [3.19]
21
+ include :
22
+ - platform : linux/riscv64
23
+ alpine_version : edge
24
+
25
+ steps :
26
+ - name : Prepare name for digest up/download
27
+ run : |
28
+ platform=${{ matrix.platform }}
29
+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
30
+
31
+ - name : Checkout Repo
32
+ uses : actions/checkout@v4
33
+
34
+ - name : Docker meta
35
+ id : meta
36
+ uses : docker/metadata-action@v5
37
+ with :
38
+ github-token : ${{ secrets.GITHUB_TOKEN }}
39
+ images : |
40
+ ${{ env.dockerhub }}
41
+ ${{ env.ghcr }}
42
+ flavor : |
43
+ latest=false
44
+ tags : |
45
+ development-v6
46
+
47
+ - name : Login to DockerHub and GitHub Container Registry
48
+ uses : ./.github/actions/login-repo
49
+ with :
50
+ docker_username : ${{ secrets.DOCKERHUB_USER }}
51
+ docker_password : ${{ secrets.DOCKERHUB_PASS }}
52
+ ghcr_username : ${{ github.repository_owner }}
53
+ ghcr_password : ${{ secrets.GITHUB_TOKEN }}
54
+
55
+ - name : Set up QEMU
56
+ uses : docker/setup-qemu-action@v3
57
+ with :
58
+ platforms : ${{ matrix.platform}}
59
+
60
+ - name : Set up Docker Buildx
61
+ uses : docker/setup-buildx-action@v3
62
+
63
+ - name : Build container and push by digest
64
+ id : build
65
+ uses : docker/build-push-action@v5
66
+ with :
67
+ context : ./src/
68
+ platforms : ${{ matrix.platform }}
69
+ build-args : |
70
+ PIHOLE_DOCKER_TAG=${{ steps.meta.outputs.version }}
71
+ alpine_version=${{ matrix.alpine_version }}
72
+ labels : ${{ steps.meta.outputs.labels }}
73
+ outputs : |
74
+ type=image,name=${{ env.dockerhub }},push-by-digest=true,name-canonical=true,push=true
75
+
76
+ - name : Export digests
77
+ run : |
78
+ mkdir -p /tmp/digests
79
+ digest_docker="${{ steps.build.outputs.digest }}"
80
+ touch "/tmp/digests/${digest_docker#sha256:}"
81
+
82
+ - name : Upload digest
83
+ uses : actions/upload-artifact@v4
84
+ with :
85
+ name : digests-${{ env.PLATFORM_PAIR }}
86
+ path : /tmp/digests/*
87
+ if-no-files-found : error
88
+ retention-days : 1
89
+
90
+ # Merge all the digests into a single file
91
+ # If we would push immediately above, the individual runners would overwrite each other's images
92
+ # https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
93
+ merge-and-deploy :
94
+ runs-on : ubuntu-latest
95
+ needs :
96
+ - build
97
+ steps :
98
+ - name : Checkout Repo
99
+ uses : actions/checkout@v4
100
+
101
+ - name : Download digests
102
+ uses : actions/download-artifact@v4
103
+ with :
104
+ path : /tmp/digests
105
+ pattern : digests-*
106
+ merge-multiple : true
107
+
108
+ - name : Set up Docker Buildx
109
+ uses : docker/setup-buildx-action@v3
110
+
111
+ - name : Docker meta
112
+ id : meta
113
+ uses : docker/metadata-action@v5
114
+ with :
115
+ github-token : ${{ secrets.GITHUB_TOKEN }}
116
+ images : |
117
+ ${{ env.dockerhub }}
118
+ ${{ env.ghcr }}
119
+ flavor : |
120
+ latest=false
121
+ tags : |
122
+ development-v6
123
+
124
+ - name : Login to DockerHub and GitHub Container Registry
125
+ uses : ./.github/actions/login-repo
126
+ with :
127
+ docker_username : ${{ secrets.DOCKERHUB_USER }}
128
+ docker_password : ${{ secrets.DOCKERHUB_PASS }}
129
+ ghcr_username : ${{ github.repository_owner }}
130
+ ghcr_password : ${{ secrets.GITHUB_TOKEN }}
131
+
132
+ - name : Create manifest list and push (DockerHub and GitHub Container Registry)
133
+ working-directory : /tmp/digests
134
+ run : |
135
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
136
+ $(printf '${{ env.dockerhub }}@sha256:%s ' *)
137
+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
138
+ $(printf '${{ env.ghcr }}@sha256:%s ' *)
139
+
140
+ - name : Inspect images
141
+ run : |
142
+ docker buildx imagetools inspect ${{ env.dockerhub }}:${{ steps.meta.outputs.version }}
143
+ docker buildx imagetools inspect ${{ env.ghcr }}:${{ steps.meta.outputs.version }}
0 commit comments