Debian Codegraph @

.github/workflows/containers.yml

raw
1 # Copyright (C) 2025 Siemens
2 #
3 # SPDX-License-Identifier: MIT
4 name: Containers
5
6 on:
7 push:
8 branches:
9 - main
10 pull_request:
11
12 jobs:
13 build_containers:
14 name: Build, test and deploy container images
15 runs-on: ubuntu-24.04
16 permissions:
17 id-token: write
18 packages: write
19 contents: read
20 attestations: write
21 steps:
22 - name: Check out repo
23 uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
24 - name: Set up docker build
25 uses: ./.github/actions/docker-init
26 with:
27 deploy-user: ${{ github.actor }}
28 deploy-token: ${{ secrets.GITHUB_TOKEN }}
29
30 - name: Build debsbom image
31 uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
32 with:
33 context: /home/runner/debsbom-clone
34 target: debsbom
35 platforms: linux/amd64
36 build-args: |
37 SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
38 DEBIAN_TAG=${{ env.DEBIAN_TAG }}
39 outputs: type=docker,rewrite-timestamp=true
40 tags: ghcr.io/${{ github.repository }}:test
41 - name: Test debsbom image
42 run: |
43 docker run ghcr.io/${{ github.repository }}:test debsbom --version
44 docker run ghcr.io/${{ github.repository }}:test debsbom generate -t spdx -t cdx
45 mkdir downloads
46 echo "guestfs-tools 1.52.3-1 source" | \
47 docker run -v$(pwd)/downloads:/mnt/downloads -i ghcr.io/${{ github.repository }}:test \
48 debsbom download --outdir /mnt/downloads --sources
49 find downloads/sources -name "guestfs-tools*" | grep .
50 - name: Complete build and deploy image
51 if: github.ref == 'refs/heads/main'
52 uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
53 id: push
54 with:
55 context: /home/runner/debsbom-clone
56 target: debsbom
57 platforms: linux/amd64,linux/arm64
58 build-args: |
59 SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
60 DEBIAN_TAG=${{ env.DEBIAN_TAG }}
61 provenance: false
62 outputs: type=registry,rewrite-timestamp=true
63 tags: ghcr.io/${{ github.repository }}:latest
64 annotations: ${{ env.DOCKER_METADATA_OUTPUT_ANNOTATIONS }}
65 - name: Attest image
66 if: github.ref == 'refs/heads/main'
67 uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
68 with:
69 subject-name: ghcr.io/${{ github.repository }}
70 subject-digest: ${{ steps.push.outputs.digest }}
71 push-to-registry: true
72
73 cleanup_ghcr_containers:
74 name: cleanup untagged containers
75 if: github.ref == 'refs/heads/main'
76 runs-on: ubuntu-24.04
77 needs: build_containers
78 permissions:
79 packages: write
80 steps:
81 - uses: dataaxiom/ghcr-cleanup-action@d52806a0dc70b430571a37da1fde39733ffd640f # v1.2.2
82 with:
83 dry-run: false
84 validate: true
85 token: ${{ secrets.GITHUB_TOKEN }}