|
1 | | -name: Build And Publish Images |
| 1 | +name: Verify And Publish Main Image |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - master |
7 | | - - develop |
8 | | - workflow_dispatch: |
9 | 7 |
|
10 | 8 | concurrency: |
11 | | - group: image-publish-${{ github.ref_name }} |
| 9 | + group: master-image-publish |
12 | 10 | cancel-in-progress: true |
13 | 11 |
|
14 | 12 | permissions: |
@@ -176,24 +174,12 @@ jobs: |
176 | 174 | - name: Prepare image metadata |
177 | 175 | id: prep |
178 | 176 | run: | |
179 | | - timestamp="$(date -u +%Y%m%d-%H%M%S)" |
180 | | - if [ "${GITHUB_REF_NAME}" = "master" ]; then |
181 | | - channel_tag="latest" |
182 | | - version_tag="${timestamp}" |
183 | | - app_version="${timestamp}" |
184 | | - elif [ "${GITHUB_REF_NAME}" = "develop" ]; then |
185 | | - channel_tag="dev-latest" |
186 | | - version_tag="dev-${timestamp}" |
187 | | - app_version="dev-${timestamp}" |
188 | | - else |
189 | | - echo "Unsupported ref ${GITHUB_REF_NAME}" >&2 |
190 | | - exit 1 |
191 | | - fi |
| 177 | + short_sha="${GITHUB_SHA::12}" |
192 | 178 |
|
193 | 179 | { |
194 | | - echo "channel_tag=${channel_tag}" |
195 | | - echo "version_tag=${version_tag}" |
196 | | - echo "app_version=${app_version}" |
| 180 | + echo "channel_tag=latest" |
| 181 | + echo "version_tag=sha-${short_sha}" |
| 182 | + echo "app_version=${short_sha}" |
197 | 183 | echo "owner_lc=${GITHUB_REPOSITORY_OWNER,,}" |
198 | 184 | } >> "$GITHUB_OUTPUT" |
199 | 185 |
|
@@ -237,77 +223,3 @@ jobs: |
237 | 223 | cache-to: type=gha,mode=max,scope=main-image-${{ github.ref_name }} |
238 | 224 | provenance: mode=max |
239 | 225 | sbom: true |
240 | | - |
241 | | - publish-agent-image: |
242 | | - name: Publish Agent Image |
243 | | - runs-on: ubuntu-latest |
244 | | - needs: |
245 | | - - verify-agent |
246 | | - permissions: |
247 | | - contents: read |
248 | | - packages: write |
249 | | - attestations: write |
250 | | - id-token: write |
251 | | - steps: |
252 | | - - name: Checkout code |
253 | | - uses: actions/checkout@v5 |
254 | | - |
255 | | - - name: Prepare image metadata |
256 | | - id: prep |
257 | | - run: | |
258 | | - timestamp="$(date -u +%Y%m%d-%H%M%S)" |
259 | | - if [ "${GITHUB_REF_NAME}" = "master" ]; then |
260 | | - channel_tag="latest" |
261 | | - version_tag="${timestamp}" |
262 | | - elif [ "${GITHUB_REF_NAME}" = "develop" ]; then |
263 | | - channel_tag="dev-latest" |
264 | | - version_tag="dev-${timestamp}" |
265 | | - else |
266 | | - echo "Unsupported ref ${GITHUB_REF_NAME}" >&2 |
267 | | - exit 1 |
268 | | - fi |
269 | | -
|
270 | | - { |
271 | | - echo "channel_tag=${channel_tag}" |
272 | | - echo "version_tag=${version_tag}" |
273 | | - echo "owner_lc=${GITHUB_REPOSITORY_OWNER,,}" |
274 | | - } >> "$GITHUB_OUTPUT" |
275 | | -
|
276 | | - - name: Extract image metadata |
277 | | - id: meta |
278 | | - uses: docker/metadata-action@v5 |
279 | | - with: |
280 | | - images: ghcr.io/${{ steps.prep.outputs.owner_lc }}/yacht-agent |
281 | | - tags: | |
282 | | - type=raw,value=${{ steps.prep.outputs.channel_tag }} |
283 | | - type=raw,value=${{ steps.prep.outputs.version_tag }} |
284 | | - labels: | |
285 | | - org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} |
286 | | - org.opencontainers.image.revision=${{ github.sha }} |
287 | | -
|
288 | | - - name: Set up QEMU |
289 | | - uses: docker/setup-qemu-action@v3 |
290 | | - |
291 | | - - name: Set up Docker Buildx |
292 | | - uses: docker/setup-buildx-action@v3 |
293 | | - |
294 | | - - name: Log in to GitHub Container Registry |
295 | | - uses: docker/login-action@v4 |
296 | | - with: |
297 | | - registry: ghcr.io |
298 | | - username: ${{ secrets.GHCR_USERNAME != '' && secrets.GHCR_USERNAME || github.actor }} |
299 | | - password: ${{ secrets.GHCR_TOKEN != '' && secrets.GHCR_TOKEN || secrets.GITHUB_TOKEN }} |
300 | | - |
301 | | - - name: Build and push agent image |
302 | | - uses: docker/build-push-action@v6 |
303 | | - with: |
304 | | - context: . |
305 | | - file: ./agent/Dockerfile |
306 | | - platforms: linux/amd64,linux/arm64 |
307 | | - push: true |
308 | | - tags: ${{ steps.meta.outputs.tags }} |
309 | | - labels: ${{ steps.meta.outputs.labels }} |
310 | | - cache-from: type=gha,scope=agent-image-${{ github.ref_name }} |
311 | | - cache-to: type=gha,mode=max,scope=agent-image-${{ github.ref_name }} |
312 | | - provenance: mode=max |
313 | | - sbom: true |
0 commit comments