|
4 | 4 | [](/LICENSE)
|
5 | 5 | [](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md)
|
6 | 6 |
|
7 |
| -# Conditional Container Builder with Fallback and Attestations (SBOMs) |
| 7 | +# Conditional Container Builder with Fallback, Attestations and SBOMs (Software Bill of Materials) |
8 | 8 |
|
9 | 9 | This action builds Docker/Podman containers conditionally using a set of directories. If any files were changed matching that, then build a container. If those files were not changed, retag an existing build.
|
10 | 10 |
|
@@ -72,6 +72,10 @@ Only GitHub Container Registry (ghcr.io) is supported so far.
|
72 | 72 | # Defaults to the current one
|
73 | 73 | repository: ${{ github.repository }}
|
74 | 74 |
|
| 75 | + # SBOM generation is enabled by default as a security best practice |
| 76 | + # String value, not boolean |
| 77 | + sbom: 'true' |
| 78 | + |
75 | 79 | # Specify token (GH or PAT), instead of inheriting one from the calling workflow
|
76 | 80 | token: ${{ secrets.GITHUB_TOKEN }}
|
77 | 81 |
|
@@ -152,49 +156,39 @@ builds:
|
152 | 156 |
|
153 | 157 | ```
|
154 | 158 |
|
155 |
| -# Permissions |
| 159 | +# Security Features |
| 160 | + |
| 161 | +This action provides two key security features: Container Attestations and Software Bill of Materials (SBOM) generation. |
156 | 162 |
|
157 |
| -It is good practice to set explicit permissions for jobs and workflows. These are applied to the GITHUB_TOKEN. Please see the [GitHub documentation](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token) for more information. |
| 163 | +## Container Attestations |
158 | 164 |
|
159 |
| -The following permissions are used by this action: |
| 165 | +[Container attestations](https://docs.github.com/en/actions/security-guides/security-hardening-with-openid-connect#about-oidc-and-container-signing) use GitHub's OIDC token to provide cryptographic proof of: |
| 166 | +- Where the container was built (GitHub Actions) |
| 167 | +- When it was built (timestamp) |
| 168 | +- What repository and workflow built it |
| 169 | +- What inputs and environment were used |
160 | 170 |
|
| 171 | +Attestations require the following permissions: |
161 | 172 | ```yaml
|
162 | 173 | permissions:
|
163 | 174 | packages: write # Required for pushing images
|
164 |
| - id-token: write # Optional: Required for OIDC token generation |
165 |
| - attestations: write # Optional: Required for creating attestations |
| 175 | + id-token: write # Required for OIDC token generation |
| 176 | + attestations: write # Required for creating attestations |
166 | 177 | ```
|
167 | 178 |
|
168 |
| -## Container Attestations |
169 |
| -
|
170 |
| -This action supports [container attestations](https://docs.github.com/en/actions/security-guides/security-hardening-with-openid-connect#about-oidc-and-container-signing) using GitHub's OIDC token. Attestations provide cryptographic verification of container images, enhancing supply chain security. |
| 179 | +If these permissions are not granted, the action will still build and push images but skip the attestation step. |
171 | 180 |
|
172 |
| -If the `id-token: write` and `attestations: write` permissions are not granted, the action will still build and push images but will skip the attestation step. This allows the action to work in environments both with and without attestation support. |
| 181 | +## Software Bill of Materials (SBOM) |
173 | 182 |
|
174 |
| -Example workflow with all permissions enabled: |
| 183 | +This action automatically generates SBOMs for all container builds using [Syft](https://github.com/anchore/syft). SBOMs provide a detailed inventory that includes: |
| 184 | +- All installed packages and their versions |
| 185 | +- Dependencies and their relationships |
| 186 | +- License information |
| 187 | +- Known vulnerabilities |
175 | 188 |
|
176 |
| -```yaml |
177 |
| -name: Build with Attestations |
178 |
| -
|
179 |
| -on: |
180 |
| - pull_request: |
181 |
| -
|
182 |
| -permissions: |
183 |
| - attestations: write |
184 |
| - id-token: write |
185 |
| - packages: write |
186 |
| -
|
187 |
| -jobs: |
188 |
| - build: |
189 |
| - runs-on: ubuntu-24.04 |
190 |
| - steps: |
191 |
| - - uses: actions/checkout@v4 |
192 |
| - - uses: bcgov/action-builder-ghcr@vX.Y.Z |
193 |
| - with: |
194 |
| - package: frontend |
195 |
| - tag_fallback: test |
196 |
| - triggers: ('frontend/') |
197 |
| -``` |
| 189 | +Two SBOM formats are generated and uploaded as workflow artifacts: |
| 190 | +- CycloneDX JSON |
| 191 | +- SPDX JSON |
198 | 192 |
|
199 | 193 | # Outputs
|
200 | 194 |
|
|
0 commit comments