# Copyright (C) 2025 Siemens # # SPDX-License-Identifier: MIT name: Containers on: push: branches: - main pull_request: jobs: build_containers: name: Build, test and deploy container images runs-on: ubuntu-24.04 permissions: id-token: write packages: write contents: read attestations: write steps: - name: Check out repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Set up docker build uses: ./.github/actions/docker-init with: deploy-user: ${{ github.actor }} deploy-token: ${{ secrets.GITHUB_TOKEN }} - name: Build debsbom image uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 with: context: /home/runner/debsbom-clone target: debsbom platforms: linux/amd64 build-args: | SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }} DEBIAN_TAG=${{ env.DEBIAN_TAG }} outputs: type=docker,rewrite-timestamp=true tags: ghcr.io/${{ github.repository }}:test - name: Test debsbom image run: | docker run ghcr.io/${{ github.repository }}:test debsbom --version docker run ghcr.io/${{ github.repository }}:test debsbom generate -t spdx -t cdx mkdir downloads echo "guestfs-tools 1.52.3-1 source" | \ docker run -v$(pwd)/downloads:/mnt/downloads -i ghcr.io/${{ github.repository }}:test \ debsbom download --outdir /mnt/downloads --sources find downloads/sources -name "guestfs-tools*" | grep . - name: Complete build and deploy image if: github.ref == 'refs/heads/main' uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 id: push with: context: /home/runner/debsbom-clone target: debsbom platforms: linux/amd64,linux/arm64 build-args: | SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }} DEBIAN_TAG=${{ env.DEBIAN_TAG }} provenance: false outputs: type=registry,rewrite-timestamp=true tags: ghcr.io/${{ github.repository }}:latest annotations: ${{ env.DOCKER_METADATA_OUTPUT_ANNOTATIONS }} - name: Attest image if: github.ref == 'refs/heads/main' uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 with: subject-name: ghcr.io/${{ github.repository }} subject-digest: ${{ steps.push.outputs.digest }} push-to-registry: true cleanup_ghcr_containers: name: cleanup untagged containers if: github.ref == 'refs/heads/main' runs-on: ubuntu-24.04 needs: build_containers permissions: packages: write steps: - uses: dataaxiom/ghcr-cleanup-action@d52806a0dc70b430571a37da1fde39733ffd640f # v1.2.2 with: dry-run: false validate: true token: ${{ secrets.GITHUB_TOKEN }}