|
35 | 35 | helm-chart-package: |
36 | 36 | description: Helm chart package name |
37 | 37 | value: ${{ jobs.helm-chart.outputs.package }} |
| 38 | + subchart-name: |
| 39 | + description: CRD subchart OCI name |
| 40 | + value: ${{ jobs.crd-subchart.outputs.name }} |
| 41 | + subchart-tag: |
| 42 | + description: CRD subchart tag |
| 43 | + value: ${{ jobs.crd-subchart.outputs.tag }} |
| 44 | + subchart-package: |
| 45 | + description: CRD subchart package name |
| 46 | + value: ${{ jobs.crd-subchart.outputs.package }} |
38 | 47 |
|
39 | 48 | permissions: |
40 | 49 | contents: read |
@@ -373,3 +382,126 @@ jobs: |
373 | 382 | uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 |
374 | 383 | with: |
375 | 384 | sarif_file: trivy-results.sarif |
| 385 | + |
| 386 | + crd-subchart: |
| 387 | + if: github.repository == 'kube-logging/logging-operator' |
| 388 | + name: CRD subchart |
| 389 | + runs-on: ubuntu-latest |
| 390 | + |
| 391 | + permissions: |
| 392 | + contents: read |
| 393 | + packages: write |
| 394 | + id-token: write |
| 395 | + security-events: write |
| 396 | + |
| 397 | + outputs: |
| 398 | + name: ${{ steps.oci-chart-name.outputs.value }} |
| 399 | + tag: ${{ steps.version.outputs.value }} |
| 400 | + package: ${{ steps.build.outputs.package }} |
| 401 | + |
| 402 | + env: |
| 403 | + subchartPath: logging-operator/charts/crds |
| 404 | + subchartName: crds |
| 405 | + |
| 406 | + steps: |
| 407 | + - name: Checkout repository |
| 408 | + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 |
| 409 | + |
| 410 | + - name: Set up Helm |
| 411 | + uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 |
| 412 | + with: |
| 413 | + version: v3.12.0 |
| 414 | + |
| 415 | + - name: Set up Cosign |
| 416 | + uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0 |
| 417 | + |
| 418 | + - name: Set chart name |
| 419 | + id: chart-name |
| 420 | + run: echo "value=${{ github.event.repository.name }}/$subchartName" >> "$GITHUB_OUTPUT" |
| 421 | + |
| 422 | + - name: Set OCI registry name |
| 423 | + id: oci-registry-name |
| 424 | + run: echo "value=ghcr.io/${{ github.repository_owner }}/helm-charts" >> "$GITHUB_OUTPUT" |
| 425 | + |
| 426 | + - name: Set OCI chart name |
| 427 | + id: oci-chart-name |
| 428 | + run: echo "value=${{ steps.oci-registry-name.outputs.value }}/${{ steps.chart-name.outputs.value }}" >> "$GITHUB_OUTPUT" |
| 429 | + |
| 430 | + - name: Helm lint |
| 431 | + run: helm lint charts/$subchartPath |
| 432 | + |
| 433 | + - name: Determine raw version |
| 434 | + uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 |
| 435 | + id: version |
| 436 | + with: |
| 437 | + cond: ${{ inputs.release }} |
| 438 | + if_true: ${{ github.ref_name }} |
| 439 | + if_false: 0.0.0 |
| 440 | + |
| 441 | + - name: Helm package |
| 442 | + id: build |
| 443 | + run: | |
| 444 | + helm package charts/$subchartPath --version ${{ steps.version.outputs.value }} --app-version ${{ steps.version.outputs.value }} |
| 445 | + echo "package=${{ github.workspace }}/$subchartName-${{ steps.version.outputs.value }}.tgz" >> "$GITHUB_OUTPUT" |
| 446 | + |
| 447 | + - name: Upload chart as artifact |
| 448 | + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 |
| 449 | + with: |
| 450 | + name: "[${{ github.job }}] Helm chart" |
| 451 | + path: ${{ steps.build.outputs.package }} |
| 452 | + |
| 453 | + - name: Login to GitHub Container Registry |
| 454 | + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0 |
| 455 | + with: |
| 456 | + registry: ghcr.io |
| 457 | + username: ${{ github.actor }} |
| 458 | + password: ${{ github.token }} |
| 459 | + if: inputs.publish && inputs.release |
| 460 | + |
| 461 | + - name: Helm push |
| 462 | + id: push |
| 463 | + run: | |
| 464 | + helm push ${{ steps.build.outputs.package }} oci://${{ steps.oci-registry-name.outputs.value }}/${{ github.event.repository.name }} &> push-metadata.txt |
| 465 | + echo "digest=$(awk '/Digest: /{print $2}' push-metadata.txt)" >> "$GITHUB_OUTPUT" |
| 466 | + env: |
| 467 | + HELM_REGISTRY_CONFIG: ~/.docker/config.json |
| 468 | + if: inputs.publish && inputs.release |
| 469 | + |
| 470 | + - name: Sign chart with GitHub OIDC Token |
| 471 | + if: ${{ inputs.publish && inputs.release && github.repository_owner == 'kube-logging' }} # Check if the workflow is called by the same GitHub organization |
| 472 | + env: |
| 473 | + DIGEST: ${{ steps.push.outputs.digest }} |
| 474 | + run: cosign sign --yes --rekor-url "https://rekor.sigstore.dev/" "${{ steps.oci-chart-name.outputs.value }}@${DIGEST}" |
| 475 | + |
| 476 | + - name: Verify signed chart with cosign |
| 477 | + if: ${{ inputs.publish && inputs.release && github.repository_owner == 'kube-logging' }} # Check if the workflow is called by the same GitHub organization |
| 478 | + env: |
| 479 | + DIGEST: ${{ steps.push.outputs.digest }} |
| 480 | + run: | |
| 481 | + cosign verify "${{ steps.oci-chart-name.outputs.value }}@${DIGEST}" \ |
| 482 | + --rekor-url "https://rekor.sigstore.dev/" \ |
| 483 | + --certificate-identity "https://github.com/${{ github.repository }}/.github/workflows/artifacts.yaml@${{ github.ref }}" \ |
| 484 | + --certificate-oidc-issuer "https://token.actions.githubusercontent.com" | jq |
| 485 | + |
| 486 | + - name: Run Trivy vulnerability scanner |
| 487 | + uses: aquasecurity/trivy-action@915b19bbe73b92a6cf82a1bc12b087c9a19a5fe2 # 0.28.0 |
| 488 | + env: |
| 489 | + TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2 |
| 490 | + TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:1 |
| 491 | + with: |
| 492 | + scan-type: config |
| 493 | + scan-ref: charts/${{ steps.chart-name.outputs.value }} |
| 494 | + format: sarif |
| 495 | + output: trivy-results.sarif |
| 496 | + |
| 497 | + - name: Upload Trivy scan results as artifact |
| 498 | + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 |
| 499 | + with: |
| 500 | + name: "[${{ github.job }}] Trivy scan results" |
| 501 | + path: trivy-results.sarif |
| 502 | + retention-days: 5 |
| 503 | + |
| 504 | + - name: Upload Trivy scan results to GitHub Security tab |
| 505 | + uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 |
| 506 | + with: |
| 507 | + sarif_file: trivy-results.sarif |
0 commit comments