-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yaml
108 lines (103 loc) · 4.29 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: "Build Multi-Platform image"
description: "Build Multi-Platform image using Gradle"
outputs:
image-tag:
description: "The tag of the docker image."
value: ${{ steps.meta.outputs.tags }}
inputs:
platforms:
description: "Architectures for the created image (comma separated)"
required: false
default: "linux/amd64,linux/arm64"
type: string
image-name:
description: "Name of Docker image."
required: false
default: "${{ github.event.repository.name }}"
full-image-name:
description: "Full name of image (registry/image). The image should be provided without a tag."
required: true
allow-insecure-registries:
description: "Whether to allow insecure registries or not. (Default is false)"
required: false
default: "false"
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 microsoft)"
required: false
default: "microsoft"
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 image should be built (If not specified, an 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/[email protected]
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: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image-name }}
tags: |
event=tag,type=semver,pattern={{version}}
event=push,type=raw,value=pipeline-${{ github.run_id }}-git-{{sha}},enable=${{ github.ref_type != 'tag' }}
flavor: |
latest=false
- name: Build Docker image
run: |
./gradlew ${{ inputs.subproject && format('{0}:', inputs.subproject) || '' }}jib \
--info --stacktrace \
--image=${{ inputs.image-name }} \
-Djib.from.platforms=${{ inputs.platforms }} \
${{ 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 }}$(echo ${{ steps.meta.outputs.tags }} | sed 's/.*\(:.*\)/\1/') \
$([[ "${{ github.ref_type }}" == "tag" ]] && echo "-Djib.to.tags=latest") \
${{ inputs.gradle-refresh-dependencies == 'true' && '--refresh-dependencies' || '' }} \
${{ inputs.allow-insecure-registries == 'true' && '-Djib.allowInsecureRegistries=true' || '' }}
shell: bash
working-directory: ${{ inputs.working-directory }}