Log messag ein dockerfile #30
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
| # SPDX-FileCopyrightText: 2024 Deutsche Telekom AG | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Publish | |
| on: | |
| push: | |
| branches: ["main"] | |
| env: | |
| REGISTRY_URL: ghcr.io | |
| REGISTRY_USERNAME: ${{ github.actor }} | |
| REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
| REGISTRY_NAMESPACE: sk-ai-net | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Build WASM target | |
| env: | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| for dir in */ ; do | |
| # Check if the directory contains a build.gradle.kts file | |
| if [ -f "${dir}build.gradle.kts" ]; then | |
| echo "==> Building project in directory: ${dir}" | |
| ( | |
| cd "$dir" || exit 1 | |
| ./gradlew clean :composeApp:wasmJsBrowserProductionWebpack | |
| ) | |
| else | |
| echo "Skipping ${dir} (no build.gradle.kts found)" | |
| fi | |
| done | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and Push Docker image with wasm web app | |
| env: | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Iterate through each subdirectory in the current directory | |
| for dir in */ ; do | |
| # Check if the directory contains a Dockerfile | |
| if [ -f "${dir}Dockerfile" ]; then | |
| # Extract version from gradle.properties if exists | |
| version="latest" | |
| if [ -f "${dir}gradle.properties" ]; then | |
| version=$(grep '^version=' "${dir}gradle.properties" | cut -d'=' -f2) | |
| fi | |
| # Convert directory name to lowercase and remove trailing slash | |
| imagename=$(echo "${dir%/}" | tr '[:upper:]' '[:lower:]') | |
| echo "==> Building Docker image '${imagename}' from directory: ${dir}" | |
| ( | |
| cd "$dir" || exit 1 | |
| docker build \ | |
| --build-arg GITHUB_ACTOR="$GITHUB_ACTOR" \ | |
| --build-arg GITHUB_TOKEN="$GITHUB_TOKEN" \ | |
| --build-arg VERSION=$version \ | |
| -t ghcr.io/sk-ai-net/samples-$imagename:$version . | |
| docker push ghcr.io/sk-ai-net/samples-$imagename:$version | |
| ) | |
| else | |
| echo "Skipping ${dir} (no Dockerfile found)" | |
| fi | |
| done |