|
25 | 25 | env: |
26 | 26 | REPO_SLUG: moby/vpnkit-bin |
27 | 27 | jobs: |
28 | | - prepare: |
29 | | - runs-on: ubuntu-24.04 |
30 | | - timeout-minutes: 20 |
31 | | - outputs: |
32 | | - platforms: ${{ steps.platforms.outputs.matrix }} |
33 | | - steps: |
34 | | - - |
35 | | - name: Checkout |
36 | | - uses: actions/checkout@v4 |
37 | | - - |
38 | | - name: Docker meta |
39 | | - id: meta |
40 | | - uses: docker/metadata-action@v5 |
41 | | - with: |
42 | | - images: | |
43 | | - ${{ env.REPO_SLUG }} |
44 | | - tags: | |
45 | | - type=semver,pattern={{version}} |
46 | | - type=ref,event=branch |
47 | | - type=ref,event=pr |
48 | | - type=sha |
49 | | - - |
50 | | - name: Rename meta bake definition file |
51 | | - # see https://github.com/docker/metadata-action/issues/381#issuecomment-1918607161 |
52 | | - run: | |
53 | | - bakeFile="${{ steps.meta.outputs.bake-file }}" |
54 | | - mv "${bakeFile#cwd://}" "/tmp/bake-meta.json" |
55 | | - - |
56 | | - name: Upload meta bake definition |
57 | | - uses: actions/upload-artifact@v4 |
58 | | - with: |
59 | | - name: bake-meta |
60 | | - path: /tmp/bake-meta.json |
61 | | - if-no-files-found: error |
62 | | - retention-days: 1 |
63 | | - - |
64 | | - name: Create platforms matrix |
65 | | - id: platforms |
66 | | - run: | |
67 | | - echo "matrix=$(docker buildx bake bin-image --print | jq -cr '.target."bin-image".platforms')" >>${GITHUB_OUTPUT} |
68 | | -
|
69 | 28 | build: |
70 | | - runs-on: ${{ contains(matrix.platform, 'arm') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }} |
71 | | - timeout-minutes: 45 # guardrails timeout for the whole job |
72 | | - needs: |
73 | | - - prepare |
74 | | - if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') |
75 | | - strategy: |
76 | | - fail-fast: false |
77 | | - matrix: |
78 | | - platform: ${{ fromJson(needs.prepare.outputs.platforms) }} |
79 | | - steps: |
80 | | - - |
81 | | - name: Checkout |
82 | | - uses: actions/checkout@v4 |
83 | | - with: |
84 | | - fetch-depth: 0 |
85 | | - - |
86 | | - name: Prepare |
87 | | - run: | |
88 | | - platform=${{ matrix.platform }} |
89 | | - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
90 | | - - |
91 | | - name: Download meta bake definition |
92 | | - uses: actions/download-artifact@v4 |
93 | | - with: |
94 | | - name: bake-meta |
95 | | - path: /tmp |
96 | | - - |
97 | | - name: Set up QEMU |
98 | | - uses: docker/setup-qemu-action@v3 |
99 | | - - |
100 | | - name: Set up Docker Buildx |
101 | | - uses: docker/setup-buildx-action@v3 |
102 | | - with: |
103 | | - buildkitd-flags: --debug |
104 | | - - |
105 | | - name: Login to Docker Hub |
106 | | - if: github.event_name != 'pull_request' && github.repository == 'moby/vpnkit' |
107 | | - uses: docker/login-action@v3 |
108 | | - with: |
109 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
110 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
111 | | - - |
112 | | - name: Build |
113 | | - id: bake |
114 | | - uses: docker/bake-action@v6 |
115 | | - with: |
116 | | - source: . |
117 | | - files: | |
118 | | - ./docker-bake.hcl |
119 | | - /tmp/bake-meta.json |
120 | | - targets: bin-image |
121 | | - set: | |
122 | | - *.platform=${{ matrix.platform }} |
123 | | - *.output=type=image,name=${{ env.REPO_SLUG }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' && github.repository == 'moby/vpnkit' }} |
124 | | - *.tags= |
125 | | - - |
126 | | - name: Export digest |
127 | | - if: github.event_name != 'pull_request' && github.repository == 'moby/vpnkit' |
128 | | - run: | |
129 | | - mkdir -p /tmp/digests |
130 | | - digest="${{ fromJSON(steps.bake.outputs.metadata)['bin-image']['containerimage.digest'] }}" |
131 | | - touch "/tmp/digests/${digest#sha256:}" |
132 | | - - |
133 | | - name: Upload digest |
134 | | - if: github.event_name != 'pull_request' && github.repository == 'moby/vpnkit' |
135 | | - uses: actions/upload-artifact@v4 |
136 | | - with: |
137 | | - name: digests-${{ env.PLATFORM_PAIR }} |
138 | | - path: /tmp/digests/* |
139 | | - if-no-files-found: error |
140 | | - retention-days: 1 |
141 | | - |
142 | | - merge: |
143 | | - runs-on: ubuntu-24.04 |
144 | | - timeout-minutes: 20 |
145 | | - needs: |
146 | | - - build |
147 | | - if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && github.event_name != 'pull_request' && github.repository == 'moby/vpnkit' |
148 | | - steps: |
149 | | - - |
150 | | - name: Download meta bake definition |
151 | | - uses: actions/download-artifact@v4 |
152 | | - with: |
153 | | - name: bake-meta |
154 | | - path: /tmp |
155 | | - - |
156 | | - name: Download digests |
157 | | - uses: actions/download-artifact@v4 |
158 | | - with: |
159 | | - path: /tmp/digests |
160 | | - pattern: digests-* |
161 | | - merge-multiple: true |
162 | | - - |
163 | | - name: Set up Docker Buildx |
164 | | - uses: docker/setup-buildx-action@v3 |
165 | | - with: |
166 | | - buildkitd-flags: --debug |
167 | | - - |
168 | | - name: Login to Docker Hub |
169 | | - uses: docker/login-action@v3 |
170 | | - with: |
171 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
172 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
173 | | - - |
174 | | - name: Create manifest list and push |
175 | | - working-directory: /tmp/digests |
176 | | - run: | |
177 | | - set -x |
178 | | - docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map("-t " + .) | join(" ")' /tmp/bake-meta.json) \ |
179 | | - $(printf '${{ env.REPO_SLUG }}@sha256:%s ' *) |
180 | | - - |
181 | | - name: Inspect image |
182 | | - run: | |
183 | | - set -x |
184 | | - docker buildx imagetools inspect ${{ env.REPO_SLUG }}:$(jq -cr '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json) |
| 29 | + uses: crazy-max/.github/.github/workflows/bake-distribute-mp.yml@d9a10e2737504a6e253f96e344cef684b0e00cb5 |
| 30 | + with: |
| 31 | + target: bin-image |
| 32 | + push: ${{ github.event_name != 'pull_request' && github.repository == 'moby/vpnkit' }} |
| 33 | + cache: false # See: https://github.com/moby/vpnkit/pull/647/files/3d4f258e7514b9cc878639f724cbb0caffa8fd98#r2032880337 |
| 34 | + meta-image: moby/vpnkit |
| 35 | + meta-tags: | |
| 36 | + type=semver,pattern={{version}} |
| 37 | + type=ref,event=branch |
| 38 | + type=ref,event=pr |
| 39 | + type=sha |
| 40 | + secrets: |
| 41 | + login-username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 42 | + login-password: ${{ secrets.DOCKERHUB_TOKEN }} |
0 commit comments