|
20 | 20 | paths-ignore: |
21 | 21 | - '**.md' |
22 | 22 |
|
23 | | -env: |
24 | | - DOCKERHUB_SLUG: anonaddy/anonaddy |
25 | | - |
26 | 23 | jobs: |
27 | | - prepare: |
28 | | - runs-on: ubuntu-latest |
29 | | - outputs: |
30 | | - matrix: ${{ steps.platforms.outputs.matrix }} |
31 | | - steps: |
32 | | - - |
33 | | - name: Checkout |
34 | | - uses: actions/checkout@v4 |
35 | | - - |
36 | | - name: Create matrix |
37 | | - id: platforms |
38 | | - run: | |
39 | | - echo "matrix=$(docker buildx bake image-all --print | jq -cr '.target."image-all".platforms')" >>${GITHUB_OUTPUT} |
40 | | - - |
41 | | - name: Show matrix |
42 | | - run: | |
43 | | - echo ${{ steps.platforms.outputs.matrix }} |
44 | | - - |
45 | | - name: Docker meta |
46 | | - id: meta |
47 | | - uses: docker/metadata-action@v5 |
48 | | - with: |
49 | | - images: | |
50 | | - ${{ env.DOCKERHUB_SLUG }} |
51 | | - tags: | |
52 | | - type=match,pattern=(.*)-r,group=1 |
53 | | - type=ref,event=pr |
54 | | - type=edge |
55 | | - labels: | |
56 | | - org.opencontainers.image.title=addy.io |
57 | | - org.opencontainers.image.description=Anonymous Email Forwarding |
58 | | - org.opencontainers.image.vendor=CrazyMax |
59 | | - - |
60 | | - name: Rename meta bake definition file |
61 | | - run: | |
62 | | - mv "${{ steps.meta.outputs.bake-file }}" "/tmp/bake-meta.json" |
63 | | - - |
64 | | - name: Upload meta bake definition |
65 | | - uses: actions/upload-artifact@v4 |
66 | | - with: |
67 | | - name: bake-meta |
68 | | - path: /tmp/bake-meta.json |
69 | | - if-no-files-found: error |
70 | | - retention-days: 1 |
71 | | - |
72 | 24 | build: |
73 | | - runs-on: ${{ startsWith(matrix.platform, 'linux/arm') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} |
74 | | - needs: |
75 | | - - prepare |
76 | | - strategy: |
77 | | - fail-fast: false |
78 | | - matrix: |
79 | | - platform: ${{ fromJson(needs.prepare.outputs.matrix) }} |
80 | | - steps: |
81 | | - - |
82 | | - name: Prepare |
83 | | - run: | |
84 | | - platform=${{ matrix.platform }} |
85 | | - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
86 | | - - |
87 | | - name: Download meta bake definition |
88 | | - uses: actions/download-artifact@v4 |
89 | | - with: |
90 | | - name: bake-meta |
91 | | - path: /tmp |
92 | | - - |
93 | | - name: Set up Docker Buildx |
94 | | - uses: docker/setup-buildx-action@v3 |
95 | | - with: |
96 | | - buildkitd-flags: "--debug" |
97 | | - - |
98 | | - name: Login to DockerHub |
99 | | - if: github.event_name != 'pull_request' |
100 | | - uses: docker/login-action@v3 |
101 | | - with: |
102 | | - username: ${{ secrets.DOCKER_USERNAME }} |
103 | | - password: ${{ secrets.DOCKER_PASSWORD }} |
104 | | - - |
105 | | - name: Build |
106 | | - id: bake |
107 | | - uses: docker/bake-action@v6 |
108 | | - with: |
109 | | - files: | |
110 | | - ./docker-bake.hcl |
111 | | - cwd:///tmp/bake-meta.json |
112 | | - targets: image |
113 | | - set: | |
114 | | - *.tags= |
115 | | - *.platform=${{ matrix.platform }} |
116 | | - *.cache-from=type=gha,scope=build-${{ env.PLATFORM_PAIR }} |
117 | | - *.cache-to=type=gha,scope=build-${{ env.PLATFORM_PAIR }} |
118 | | - *.output=type=image,"name=${{ env.DOCKERHUB_SLUG }}",push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} |
119 | | - - |
120 | | - name: Export digest |
121 | | - run: | |
122 | | - mkdir -p /tmp/digests |
123 | | - digest="${{ fromJSON(steps.bake.outputs.metadata).image['containerimage.digest'] }}" |
124 | | - touch "/tmp/digests/${digest#sha256:}" |
125 | | - - |
126 | | - name: Upload digest |
127 | | - uses: actions/upload-artifact@v4 |
128 | | - with: |
129 | | - name: digests-${{ env.PLATFORM_PAIR }} |
130 | | - path: /tmp/digests/* |
131 | | - if-no-files-found: error |
132 | | - retention-days: 1 |
133 | | - |
134 | | - merge: |
135 | | - runs-on: ubuntu-latest |
136 | | - if: github.event_name != 'pull_request' |
137 | | - needs: |
138 | | - - build |
139 | | - steps: |
140 | | - - |
141 | | - name: Download meta bake definition |
142 | | - uses: actions/download-artifact@v4 |
143 | | - with: |
144 | | - name: bake-meta |
145 | | - path: /tmp |
146 | | - - |
147 | | - name: Download digests |
148 | | - uses: actions/download-artifact@v4 |
149 | | - with: |
150 | | - path: /tmp/digests |
151 | | - pattern: digests-* |
152 | | - merge-multiple: true |
153 | | - - |
154 | | - name: Set up Docker Buildx |
155 | | - uses: docker/setup-buildx-action@v3 |
156 | | - - |
157 | | - name: Login to DockerHub |
158 | | - uses: docker/login-action@v3 |
159 | | - with: |
160 | | - username: ${{ secrets.DOCKER_USERNAME }} |
161 | | - password: ${{ secrets.DOCKER_PASSWORD }} |
162 | | - - |
163 | | - name: Create manifest list and push |
164 | | - working-directory: /tmp/digests |
165 | | - run: | |
166 | | - docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.DOCKERHUB_SLUG }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \ |
167 | | - $(printf '${{ env.DOCKERHUB_SLUG }}@sha256:%s ' *) |
168 | | - - |
169 | | - name: Inspect image |
170 | | - run: | |
171 | | - tag=$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json) |
172 | | - docker buildx imagetools inspect ${{ env.DOCKERHUB_SLUG }}:${tag} |
| 25 | + uses: crazy-max/.github/.github/workflows/bake-distribute-mp.yml@0acc187b016a2946786f201397bbcfb2c530ffc7 |
| 26 | + permissions: |
| 27 | + # same as global permissions |
| 28 | + contents: read |
| 29 | + with: |
| 30 | + target: image-all |
| 31 | + push: ${{ github.event_name != 'pull_request' }} |
| 32 | + set-meta-labels: true |
| 33 | + meta-image: anonaddy/anonaddy |
| 34 | + meta-tags: | |
| 35 | + type=match,pattern=(.*)-r,group=1 |
| 36 | + type=ref,event=pr |
| 37 | + type=edge |
| 38 | + meta-labels: | |
| 39 | + org.opencontainers.image.title=addy.io |
| 40 | + org.opencontainers.image.description=Anonymous Email Forwarding |
| 41 | + org.opencontainers.image.vendor=CrazyMax |
| 42 | + secrets: |
| 43 | + login-registry: ${{ secrets.DOCKER_USERNAME }} |
| 44 | + login-password: ${{ secrets.DOCKER_PASSWORD }} |
0 commit comments