Skip to content

Commit

Permalink
feat(ci): tie fluentd image releases to LO release workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <[email protected]>
  • Loading branch information
csatib02 committed Jan 8, 2025
1 parent 235bcb6 commit a20f169
Show file tree
Hide file tree
Showing 19 changed files with 176 additions and 652 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ jobs:
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.29.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:1
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
with:
input: image
format: sarif
Expand Down Expand Up @@ -367,7 +367,7 @@ jobs:
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.29.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:1
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
with:
scan-type: config
scan-ref: charts/${{ steps.chart-name.outputs.value }}
Expand Down Expand Up @@ -490,7 +490,7 @@ jobs:
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.29.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:1
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
with:
scan-type: config
scan-ref: charts/${{ env.subchartPath }}
Expand Down
161 changes: 161 additions & 0 deletions .github/workflows/dependency-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Dependency images

on:
workflow_call:
outputs:
fluentd-image-name:
description: Container image name
value: ${{ jobs.fluentd.outputs.name }}
fluentd-image-digest:
description: Container image digest
value: ${{ jobs.fluentd.outputs.digest }}
fluentd-image-tag:
description: Container image tag
value: ${{ jobs.fluentd.outputs.tag }}
fluentd-image-ref:
description: Container image ref
value: ${{ jobs.fluentd.outputs.ref }}

permissions:
contents: read

jobs:
fluentd:
name: Fluentd
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
id-token: write
security-events: write

outputs:
name: ${{ steps.image-name.outputs.value }}
digest: ${{ steps.build.outputs.digest }}
tag: ${{ steps.meta.outputs.version }}
ref: ${{ steps.image-ref.outputs.value }}

strategy:
matrix:
image-type:
- base
- filters
- full

steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0

- name: Set up Cosign
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0

- name: Set image name
id: image-name
run: echo "value=ghcr.io/${{ github.repository }}/fluentd" >> "$GITHUB_OUTPUT"

- name: Gather build metadata
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
with:
images: ${{ steps.image-name.outputs.value }}
flavor: |
latest = false
tags: |
type=ref,event=branch
type=ref,event=pr,prefix=pr-
type=semver,pattern={{raw}}
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.description=Custom Fluentd image for the Logging operator.
org.opencontainers.image.title=Logging operator Fluentd image
org.opencontainers.image.authors=Kube logging authors
org.opencontainers.image.documentation=https://kube-logging.dev/docs/
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Build and push fluentd-${{ matrix.image-type }}
id: build
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
with:
context: images/fluentd
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
target: ${{ matrix.image-type }}
outputs: type=image,push=true,name=target,annotation-index.org.opencontainers.image.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }}

- name: Sign image with GitHub OIDC Token
if: ${{ github.repository_owner == 'kube-logging' }} # Check if the workflow is called by the same GitHub organization
env:
DIGEST: ${{ steps.build.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
images=""
for tag in ${TAGS[@]}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes --rekor-url "https://rekor.sigstore.dev/" ${images}
- name: Verify signed image with cosign
if: ${{ github.repository_owner == 'kube-logging' }} # Check if the workflow is called by the same GitHub organization
env:
DIGEST: ${{ steps.build.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
for tag in ${TAGS[@]}; do
cosign verify "${tag}@${DIGEST}" \
--rekor-url "https://rekor.sigstore.dev/" \
--certificate-identity "https://github.com/${{ github.repository }}/.github/workflows/dependency-images.yaml@${{ github.ref }}" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" | jq
done
- name: Set image ref
id: image-ref
run: echo "value=${{ steps.image-name.outputs.value }}@${{ steps.build.outputs.digest }}" >> "$GITHUB_OUTPUT"

- name: Fetch image
run: skopeo --insecure-policy copy docker://${{ steps.image-name.outputs.value }}:${{ steps.meta.outputs.version }} oci-archive:image.tar

- name: Extract OCI tarball
run: |
mkdir -p image
tar -xf image.tar -C image
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.29.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db:1
with:
input: image
format: sarif
output: trivy-results.sarif

- name: Upload Trivy scan results as artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: "[${{ github.job }}] Trivy scan results"
path: trivy-results.sarif
retention-days: 5

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
with:
sarif_file: trivy-results.sarif
9 changes: 9 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ jobs:
packages: write
id-token: write
security-events: write

dependency-images:
name: Dependency images
uses: ./.github/workflows/dependency-images.yaml
permissions:
contents: read
packages: write
id-token: write
security-events: write
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM ruby:3.3.6-alpine3.20 as base
FROM ruby:3.3.6-alpine3.20 AS base

ARG BUILD_DEPS=" \
make gcc g++ libc-dev \
wget bzip2 zlib-dev git linux-headers \
automake autoconf libtool build-base \
automake autoconf libtool build-base \
ruby-dev libc6-compat geoip-dev \
snappy-dev gnupg bash openssl-dev \
"
Expand Down Expand Up @@ -62,7 +62,7 @@ RUN apk add --no-cache $BUILD_DEPS \
USER fluent

### Image with all the filters and outputs
FROM filters as full
FROM filters AS full

ADD ./outputs/Gemfile /Gemfile.outputs
ADD ./outputs/Gemfile.lock /Gemfile.outputs.lock
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
102 changes: 0 additions & 102 deletions images/fluentd/v1.16-4.10/Dockerfile

This file was deleted.

17 changes: 0 additions & 17 deletions images/fluentd/v1.16-4.10/filters/Gemfile

This file was deleted.

Loading

0 comments on commit a20f169

Please sign in to comment.