diff --git a/actions/java-gradle-build-push-jib-multi-plaftorm/action.yaml b/actions/java-gradle-build-push-jib-multi-plaftorm/action.yaml index a86eb9795..283960197 100644 --- a/actions/java-gradle-build-push-jib-multi-plaftorm/action.yaml +++ b/actions/java-gradle-build-push-jib-multi-plaftorm/action.yaml @@ -2,26 +2,22 @@ name: "Build Multi-Platrofm image" description: "Build Multi-Platrofm image using Gradle" inputs: - image-tag: - description: "Tag of Jib Image." + additional-tags: + description: "Additional tags to be pushed to the registry. Comma seperated list." required: false - default: "" - registry-password: - description: "Password of registry." - required: false - default: "" full-image-name: - description: "Full name of image." + description: "Full name of image (registry/image:tag) If an image name is provided without a tag, 'latest' will be used. Be careful with registries that dont allow overwriting tags." + required: true + allow-insecure-registries: + description: "Whether to allow insecure registries or not. (Default is false)" required: false - default: "" - image-artifact-name: - description: "Artifact name to upload tarball image, see https://github.com/actions/upload-artifact" + default: "false" + jib-from-image: + description: "The Jib base image to use" required: false - default: "image-artifact" - image-name: - description: "Name of Docker image." + class: + description: "The entrypoint class to be used for the image" required: false - default: "${{ github.event.repository.name }}" java-distribution: description: "Java distribution to be installed. (Default is microsoft)" required: false @@ -57,9 +53,6 @@ inputs: subproject: description: "The Gradle subproject for which the tarball image should be built (If not specified, a tarball image for the root project will be built)" required: false - jib-from-image: - description: "The Jib base image to use" - required: false runs: using: "composite" steps: @@ -69,7 +62,7 @@ runs: lfs: ${{ inputs.download-lfs-files }} - name: Set up Gradle with version ${{ inputs.gradle-version }} - uses: bakdata/ci-templates/actions/java-gradle-setup@1.42.0 + uses: bakdata/ci-templates/actions/java-gradle-setup@tiedemann/adjust-with-metadata-action with: java-distribution: ${{ inputs.java-distribution }} java-version: ${{ inputs.java-version }} @@ -77,20 +70,41 @@ runs: gradle-cache: ${{ inputs.gradle-cache }} gradle-cache-read-only: ${{ inputs.gradle-cache-read-only }} + - name: Process inputs + id: process-inputs + run: | + # Extract the image name from the full image name + echo "IMAGE_NAME=$(echo "${{ inputs.full-image-name }}" | cut -d ':' -f 1)" >> "$GITHUB_OUTPUT" + IFS=',' read -r -a tags <<< "${{ inputs.additional-tags }}" + echo "IMAGE_TAGS<> "$GITHUB_OUTPUT" + for element in "${tags[@]}" + do + echo "type=raw,$element" >> $GITHUB_OUTPUT + done + echo "EOF" >> "$GITHUB_OUTPUT" + shell: bash + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.process-inputs.outputs.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=sha + ${{ steps.process-inputs.outputs.IMAGE_TAGS }} + - name: Build Docker image run: | - ./gradlew ${{ inputs.subproject && format('{0}:', inputs.subproject) || '' }}jib \ + ./gradlew ${{ inputs.subproject && format('{0}:', inputs.subproject) || '' }} jib \ --info --stacktrace \ - --image=${{ inputs.image-name }} \ - ${{ inputs.jib-from-image && format('-Djib.from.image={0}', inputs.jib-from-image) || '' }} \ + --image=${{github.repository}}_${{ github.run_id }}_${{github.run_number}} \ -Djib.from.platforms=linux/arm64,linux/amd64 \ - -DsendCredentialsOverHttp \ - -Djib.allowInsecureRegistries=true \ - -Djib.to.image=${{ inputs.full-image-name }}:${{ inputs.image-tag }} \ - -Djib.to.tags=${{ inputs.image-tag }} \ - -Djib.to.auth.username=AWS \ - -Djib.to.auth.password=${{ inputs.registry-password }} \ - -x test \ + ${{ inputs.jib-from-image && format('-Djib.from.image={0}', inputs.jib-from-image) || '' }} \ + ${{ inputs.class && format('-Djib.container.mainClass={0}', inputs.class) || '' }} \ + -Djib.to.image=${{ inputs.full-image-name }} \ + -Djib.to.tags=$(echo "${{ steps.meta.outputs.tags }}" | sed -zr 's/.*:(.*\n)/\1/gm; s/\n/,/g; s/(.*),/\1\n/g') \ ${{ inputs.gradle-refresh-dependencies == 'true' && '--refresh-dependencies' || '' }} + ${{ inputs.allow-insecure-registries == 'true' && '-Djib.allowInsecureRegistries=true -DsendCredentialsOverHttp' || '' }} shell: bash working-directory: ${{ inputs.working-directory }} diff --git a/docs/actions/java-gradle-build-push-jib-multi-plaftorm/README.md b/docs/actions/java-gradle-build-push-jib-multi-plaftorm/README.md index bb7eb847d..a5ca18726 100644 --- a/docs/actions/java-gradle-build-push-jib-multi-plaftorm/README.md +++ b/docs/actions/java-gradle-build-push-jib-multi-plaftorm/README.md @@ -25,27 +25,25 @@ steps: -| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | -| --------------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| image-tag | string | false | `""` | Tag of Jib Image. | -| registry-password | string | false | `""` | Password of registry. | -| full-image-name | string | false | `""` | Full name of image. | -| image-artifact-name | string | false | `"image-artifact"` | Artifact name to upload tarball image, see https://github.com/actions/upload-artifact | -| image-name | string | false | `"${{ github.event.repository.name }}"` | Name of Docker image. | -| java-distribution | string | false | `"microsoft"` | Java distribution to be installed. (Default is microsoft) | -| java-version | string | false | `"11"` | Java version to be installed. (Default is 11) | -| gradle-version | string | false | `"wrapper"` | Gradle version to be installed. (Default is wrapper) | -| gradle-cache | string | false | `"true"` | Whether Gradle caching is enabled or not. (Default is true) | -| gradle-cache-read-only | string | false | `"${{ github.event.repository != null && github.ref_name != github.event.repository.default_branch }}"` | Whether Gradle caching should be read-only. By default this value is 'false' for workflows on the GitHub default branch and 'true' for workflows on other branches. | -| gradle-refresh-dependencies | string | false | `"false"` | Whether Gradle should refresh dependencies. (Default is false) | -| working-directory | string | false | `"."` | Working directory of your Gradle artifacts. (Default is .) | -| download-lfs-files | string | false | `"false"` | Whether the Git checkout action should resolve LFS files or not. (Default is false) | -| subproject | string | false | | The Gradle subproject for which the tarball image should be built (If not specified, a tarball image for the root project will be built) | -| jib-from-image | string | false | | The Jib base image to use | +| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION | +| --------------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| additional-tags | string | false | | Additional tags to be pushed to the registry. Comma seperated list. | +| allow-insecure-registries | string | false | `"false"` | Whether to allow insecure registries or not. (Default is false) | +| class | string | false | | The entrypoint class to be used for the image | +| download-lfs-files | string | false | `"false"` | Whether the Git checkout action should resolve LFS files or not. (Default is false) | +| full-image-name | string | true | | Full name of image (registry/image:tag) If an image name is provided without a tag, 'latest' will be used. Be careful with registries that dont allow overwriting tags. | +| gradle-cache | string | false | `"true"` | Whether Gradle caching is enabled or not. (Default is true) | +| gradle-cache-read-only | string | false | `"${{ github.event.repository != null && github.ref_name != github.event.repository.default_branch }}"` | Whether Gradle caching should be read-only. By default this value is 'false' for workflows on the GitHub default branch and 'true' for workflows on other branches. | +| gradle-refresh-dependencies | string | false | `"false"` | Whether Gradle should refresh dependencies. (Default is false) | +| gradle-version | string | false | `"wrapper"` | Gradle version to be installed. (Default is wrapper) | +| java-distribution | string | false | `"microsoft"` | Java distribution to be installed. (Default is microsoft) | +| java-version | string | false | `"11"` | Java version to be installed. (Default is 11) | +| jib-from-image | string | false | | The Jib base image to use | +| subproject | string | false | | The Gradle subproject for which the tarball image should be built (If not specified, a tarball image for the root project will be built) | +| working-directory | string | false | `"."` | Working directory of your Gradle artifacts. (Default is .) | - ### Outputs