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 #203

Closed
wants to merge 67 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
626bd42
platform
yordanovsstoyan Apr 10, 2024
4774d96
platform
yordanovsstoyan Apr 10, 2024
b4e9073
platform
yordanovsstoyan Apr 10, 2024
db42da9
platform
yordanovsstoyan Apr 10, 2024
d8bcfa8
platform
yordanovsstoyan Apr 10, 2024
80dd032
platform
yordanovsstoyan Apr 10, 2024
00cf515
platform
yordanovsstoyan Apr 10, 2024
e59e664
mullti
yordanovsstoyan Apr 11, 2024
93264f6
mullti
yordanovsstoyan Apr 11, 2024
a00de69
mullti
yordanovsstoyan Apr 11, 2024
a7c9b0b
mullti
yordanovsstoyan Apr 11, 2024
7a00887
mullti
yordanovsstoyan Apr 11, 2024
8b417ec
mullti
yordanovsstoyan Apr 11, 2024
7c0a780
mullti
yordanovsstoyan Apr 11, 2024
aee34a0
work
yordanovsstoyan Apr 11, 2024
0e209fc
work
yordanovsstoyan Apr 11, 2024
11074c5
retreat
yordanovsstoyan Apr 16, 2024
9ca18ce
test-new-jib
yordanovsstoyan Apr 17, 2024
d4dc58a
revert
yordanovsstoyan Apr 18, 2024
4a8ee89
registry
yordanovsstoyan Apr 18, 2024
685bc0b
registry
yordanovsstoyan Apr 18, 2024
b2ba437
registry
yordanovsstoyan Apr 18, 2024
02163cc
tags
yordanovsstoyan Apr 18, 2024
594fb18
tags
yordanovsstoyan Apr 18, 2024
e727033
tags
yordanovsstoyan Apr 18, 2024
3a545c9
tags
yordanovsstoyan Apr 18, 2024
fa6b045
tags
yordanovsstoyan Apr 18, 2024
8c148c0
tags
yordanovsstoyan Apr 18, 2024
724dce7
tags
yordanovsstoyan Apr 18, 2024
9b08476
tags
yordanovsstoyan Apr 18, 2024
27bdcda
tags
yordanovsstoyan Apr 18, 2024
cc24126
tags
yordanovsstoyan Apr 18, 2024
a139e42
tags
yordanovsstoyan Apr 18, 2024
8c5ca01
tags
yordanovsstoyan Apr 19, 2024
bbc64c1
removesuffix
yordanovsstoyan Apr 19, 2024
a46fdfa
build-push-jib
yordanovsstoyan Apr 19, 2024
79e328f
image-name
yordanovsstoyan Apr 19, 2024
7c7a140
test
yordanovsstoyan Jun 11, 2024
8910270
test
yordanovsstoyan Jun 11, 2024
b0b09b1
test
yordanovsstoyan Jun 11, 2024
d5aa1b1
test
yordanovsstoyan Jun 11, 2024
6f785b6
test
yordanovsstoyan Jun 11, 2024
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
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
4 changes: 4 additions & 0 deletions actions/java-gradle-build-push-jib-multi-plaftorm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# java-gradle-build-jib

- [Description](https://github.com/bakdata/ci-templates/tree/main/docs/actions/java-gradle-build-jib)
- [References](https://github.com/bakdata/ci-templates/tree/main/docs/actions/java-gradle-build-jib)
105 changes: 105 additions & 0 deletions actions/java-gradle-build-push-jib-multi-plaftorm/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: "Build Multi-Platrofm image"
description: "Build Multi-Platrofm image using Gradle"

inputs:
additional-tags:
description: "Additional tags to be pushed to the registry. Comma seperated list."
required: false
full-image-name:
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
class:
description: "The entrypoint class to be used for the image"
required: false
java-distribution:
description: "Java distribution to be installed. (Default is temurin)"
required: false
default: "temurin"
java-version:
description: "Java version to be installed. (Default is 11)"
required: false
default: "11"
gradle-version:
description: "Gradle version to be installed. (Default is wrapper)"
required: false
default: "wrapper"
gradle-cache:
description: "Whether Gradle caching is enabled or not. (Default is true)"
required: false
default: "true"
gradle-cache-read-only:
description: "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."
required: false
default: ${{ github.event.repository != null && github.ref_name != github.event.repository.default_branch }}
gradle-refresh-dependencies:
description: "Whether Gradle should refresh dependencies. (Default is false)"
required: false
default: "false"
working-directory:
description: "Working directory of your Gradle artifacts. (Default is .)"
required: false
default: "."
download-lfs-files:
description: "Whether the Git checkout action should resolve LFS files or not. (Default is false)"
required: false
default: "false"
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
runs:
using: "composite"
steps:
- name: Check out repository
uses: bakdata/ci-templates/actions/[email protected]
with:
lfs: ${{ inputs.download-lfs-files }}

- name: Set up Gradle with version ${{ inputs.gradle-version }}
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 \
--info --stacktrace \
--image=${{github.repository}}_${{ github.run_id }}_${{github.run_number}} \
-Djib.from.platforms=linux/arm64,linux/amd64 \
${{ 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 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Description java-gradle-build-push-jib-multi-platform composite action

This action builds and pushes a multi-plaform image using [Jib Gradle](https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin) to a private image registry.

## Usage

```yaml
steps:
- name: Build multi-plaform image
uses: bakdata/ci-templates/actions/java-gradle-build-push-jib-multi-platform@main
with:
full-image-name: "registry/image-name" # (Optional)
registry-password: "registry-password" # (Optional)
image-tag: "tag" # (Optional)
image-artifact-name: "image-artifact" # (Optional)
java-distribution: "microsoft" # (Optional)
java-version: "11" # (Optional)
gradle-version: "wrapper" # (Optional)
working-directory: "." # (Optional)
```

## References

### Inputs

<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->

| 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 |

<!-- AUTO-DOC-INPUT:END -->


### Outputs

<!-- AUTO-DOC-OUTPUT:START - Do not remove or modify this section -->

No outputs.

<!-- AUTO-DOC-OUTPUT:END -->

### Secrets
Loading