File: containers.yml

package info (click to toggle)
debsbom 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,248 kB
  • sloc: python: 5,965; makefile: 31
file content (85 lines) | stat: -rw-r--r-- 2,875 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# 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@v4
      - 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@v6
        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@v6
        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@v1
        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@cd0cdb900b5dbf3a6f2cc869f0dbb0b8211f50c4 #v1.0.16
        with:
          dry-run: false
          validate: true
          token: ${{ secrets.GITHUB_TOKEN }}