Merge branch 'eclipse-sw360:main' into main #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copyright (c) Helio Chissini de Castro, 2023. Part of the SW360 Frontend 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 | |
| # License-Filename: LICENSE | |
| name: Docker Build | |
| 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: | |
| docker_push: | |
| name: Build Docker Image | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout source code | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0 | |
| - name: Install Cosign | |
| uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| #------------------------------------------------ | |
| # SW360 Frontend | |
| - name: Extract components metadata (tags, labels) runtime image | |
| id: meta_runtime | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.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=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| type=ref,event=tag | |
| type=raw,value=main,enable={{is_default_branch}} | |
| labels: | | |
| org.opencontainers.image.licenses=EPL-2.0 | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| - name: Build sw360 frontend build container | |
| id: build_frontend | |
| uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 | |
| with: | |
| context: . | |
| push: ${{ github.event_name != 'pull_request' }} | |
| load: false | |
| tags: ${{ steps.meta_runtime.outputs.tags }} | |
| labels: ${{ steps.meta_runtime.outputs.labels }} | |
| build-args: | | |
| NEXT_PUBLIC_SW360_API_URL=https://localhost | |
| cache-from: type=gha,scope=runtime | |
| cache-to: type=gha,scope=runtime,mode=max | |
| provenance: mode=max | |
| sbom: true | |
| - name: Sign the image | |
| if: github.event_name != 'pull_request' | |
| env: | |
| TAGS: ${{ steps.meta_runtime.outputs.tags }} | |
| DIGEST: ${{ steps.build_frontend.outputs.digest }} | |
| run: | | |
| images="" | |
| for tag in ${TAGS}; do | |
| images+="${tag}@${DIGEST} " | |
| done | |
| cosign sign --yes ${images} |