Skip to content

SW360 Container

SW360 Container #424

# -----------------------------------------------------------------------------
# Copyright Helio Chissini de Castro 2022-2025
# Copyright Cariad SE 2024
# Part of the SW360 Project.
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# -----------------------------------------------------------------------------
name: SW360 Container
on:
schedule:
- cron: '0 0 * * *' # Midnight
workflow_dispatch:
pull_request:
paths:
- 'Dockerfile'
push:
branches:
- main
tags:
- '*'
paths-ignore:
- '**.md'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
permissions:
contents: read
jobs:
sw360_version:
name: SW360 Version
runs-on: ubuntu-24.04
outputs:
sw360_version: ${{ steps.pom_version.outputs.SW360_VERSION }}
timestamp: ${{ steps.pom_version.outputs.TIMESTAMP }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- name: Checkout main repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up JDK 21
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: '21'
cache: 'maven'
distribution: 'temurin'
- name: Get revision from pom.xml
id: pom_version
run: |
echo "SW360_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_OUTPUT"
echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> "$GITHUB_ENV"
sw360_image:
name: SW360 Runtime image
needs: [sw360_version]
runs-on: ubuntu-24.04
permissions:
packages: write
id-token: write
env:
SW360_VERSION: ${{ needs.sw360_version.outputs.sw360_version }}
TIMESTAMP: ${{ needs.sw360_version.outputs.timestamp }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- name: Checkout main repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Login to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup QEMU
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Install Cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Extract components metadata (tags, labels) runtime image
id: meta_sw360
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=schedule,pattern={{date 'YYYYMMDD'}}
type=schedule,pattern=nightly
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=sha,enable=true,prefix=sha-,format=short
type=ref,event=tag
type=raw,value=main,enable={{is_default_branch}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
labels: |
org.opencontainers.image.licenses=EPL-2.0
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
- name: Extract components metadata (tags, labels) KeyCloak image
id: meta_keycloak
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}/keycloak
tags: |
type=schedule,pattern=nightly
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=ref,event=tag
type=raw,value=main,enable={{is_default_branch}}
type=raw,value=26.5.5,enable=true
labels: |
org.opencontainers.image.licenses=EPL-2.0
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
- name: SW360 image
id: build_sw360
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
target: sw360
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64
tags: ${{ steps.meta_sw360.outputs.tags }}
labels: ${{ steps.meta_sw360.outputs.labels }}
provenance: mode=max
sbom: true
env:
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
- name: KeyCloak image
id: build_keycloak
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
with:
context: .
target: keycloak
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64
tags: ${{ steps.meta_keycloak.outputs.tags }}
labels: ${{ steps.meta_keycloak.outputs.labels }}
provenance: mode=max
sbom: true
env:
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
- name: Sign the images
if: github.event_name != 'pull_request'
env:
TAGS: ${{ steps.meta_sw360.outputs.tags }}
DIGEST: ${{ steps.build_sw360.outputs.digest }}
KC_TAGS: ${{ steps.meta_keycloak.outputs.tags }}
KC_DIGEST: ${{ steps.build_keycloak.outputs.digest }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
for tag in ${KC_TAGS}; do
images+="${tag}@${KC_DIGEST} "
done
cosign sign --yes ${images}