Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata action to jib push / Merge build+push #201

Merged
merged 27 commits into from
Jun 25, 2024
Merged
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
18b3efc
feat: add auto tagging with metadata action && refactor to account fo…
0xkubectl Jun 14, 2024
49a678a
debug: lets see if this works
0xkubectl Jun 14, 2024
90ac4ec
fix: remove wrong docker metadata type
0xkubectl Jun 14, 2024
7a34928
fix: add readd correct branch config
0xkubectl Jun 14, 2024
f3845cd
fix: gh action cannot propery deal with strings lol
0xkubectl Jun 14, 2024
ce29482
impl: add action preprocess
0xkubectl Jun 18, 2024
cf0139f
debug: add debug output
0xkubectl Jun 18, 2024
27e43bd
fix: sneaky echo missing
0xkubectl Jun 18, 2024
f6f54f2
test: use docker action to generate full tags
0xkubectl Jun 18, 2024
f867c32
fix: plumbing done i think
0xkubectl Jun 18, 2024
e0c2163
fix: idk proper ident or sth?
0xkubectl Jun 20, 2024
8810483
debug: add some debug stuff
0xkubectl Jun 20, 2024
265b4b1
fix: remove debugging
0xkubectl Jun 20, 2024
29c7cbe
fix: add more robust image name
0xkubectl Jun 20, 2024
5fff0a0
fix: use termuin java distribution cuz base image need mp
0xkubectl Jun 20, 2024
fc5307e
bump: use bumped java grade action
0xkubectl Jun 20, 2024
9a74129
fix: broken step reference
0xkubectl Jun 20, 2024
a97ad0c
fix: comments breaks script
0xkubectl Jun 21, 2024
b06b707
fix: more sed magic
0xkubectl Jun 21, 2024
4793925
debug: add debug output to jib call
0xkubectl Jun 21, 2024
9987c8f
fix: add brackets around the username and password
0xkubectl Jun 21, 2024
6aa0740
debug: try different quotes :O
0xkubectl Jun 21, 2024
809a9fe
debug: maybe without the escape
0xkubectl Jun 21, 2024
0f9ab3a
debug: try double quotes
0xkubectl Jun 21, 2024
5890b96
fix: assume that jib is logged in
0xkubectl Jun 23, 2024
9f95eee
fix: add insecure flag + revert to microsoft
0xkubectl Jun 25, 2024
c55a02a
docs: update docs
0xkubectl Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 41 additions & 32 deletions actions/java-gradle-build-push-jib-multi-plaftorm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +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."
required: false
default: ""
image-artifact-name:
description: "Artifact name to upload tarball image, see https://github.com/actions/upload-artifact"
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
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)"
description: "Java distribution to be installed. (Default is temurin)"
required: false
default: "microsoft"
default: "temurin"
java-version:
description: "Java version to be installed. (Default is 11)"
required: false
Expand Down Expand Up @@ -57,9 +49,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:
Expand All @@ -69,28 +58,48 @@ 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 }}
gradle-version: ${{ inputs.gradle-version }}
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<<EOF" >> "$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' || '' }}
shell: bash
working-directory: ${{ inputs.working-directory }}
Loading