Skip to content

Commit d3aa683

Browse files
committed
Cleanup
- Rewrite workflows with reusable workflows - Rename compose files to compose.yml
1 parent cbbd2db commit d3aa683

36 files changed

+430
-162
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and deploy OCI image to registry
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
image-jvm-type:
7+
description: JVM type for output image
8+
type: string
9+
default: jre
10+
image-jvm-version:
11+
description: JVM version for output image
12+
type: string
13+
default: 17
14+
image-name:
15+
description: The output image name
16+
type: string
17+
required: true
18+
java-build-distribution:
19+
description: Java distribution to use for build
20+
type: string
21+
default: temurin
22+
java-build-version:
23+
description: Java version to build with
24+
type: string
25+
default: 17
26+
registry:
27+
description: The registry to deploy to
28+
type: string
29+
required: true
30+
tags:
31+
description: Comma separated list of docker tags to create
32+
type: string
33+
34+
jobs:
35+
generate-jvm-tag:
36+
uses: ./.github/workflows/generate-jvm-tag.yml
37+
with:
38+
jvm-type: ${{ inputs.jvm-type }}
39+
jvm-version: ${{ inputs.jvm-version }}
40+
41+
build-and-push:
42+
name: Build and deploy Java ${{ needs.generate-jvm-tag.outputs.jvm-tag }} OCI image to registry
43+
needs: generate-jvm-tag
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
49+
- name: Set up JDK ${{ inputs.java-build-version }}
50+
uses: actions/setup-java@v4
51+
with:
52+
distribution: ${{ inputs.java-build-distribution }}
53+
java-version: ${{ inputs.java-build-version }}
54+
55+
- name: Setup Gradle
56+
uses: gradle/actions/setup-gradle@v3
57+
58+
- name: Add tags environment variable
59+
if: inputs.tags != ''
60+
run: echo "TAGS=-PdockerTags=${{ inputs.tags }}" >> $GITHUB_ENV
61+
62+
- name: Setup Docker Hub credentials
63+
if: inputs.registry == 'docker.io'
64+
run: |
65+
echo "DOCKER_USERNAME=${{ secrets.DOCKERHUB_USERNAME }}" >> $GITHUB_ENV
66+
echo "DOCKER_PASSWORD=${{ secrets.DOCKERHUB_TOKEN }}" >> $GITHUB_ENV
67+
68+
- name: Setup GitHub Container Registry credentials
69+
if: inputs.registry == 'ghcr.io'
70+
run: |
71+
echo "DOCKER_USERNAME=${{ github.actor }}" >> $GITHUB_ENV
72+
echo "DOCKER_PASSWORD=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
73+
74+
- name: Build and deploy OCI image
75+
run: >
76+
./gradlew bootBuildImage
77+
-PjvmType=${{ inputs.image-jvm-type }}
78+
-PjdkVersion=${{ inputs.image-jvm-version }}
79+
-PdockerUsername=${{ env.DOCKER_USERNAME }}
80+
-PdockerPassword=${{ env.DOCKER_PASSWORD }}
81+
$TAGS
82+
--imageName=${{ inputs.registry }}/${{ inputs.image-name }}
83+
--publishImage

.github/workflows/ci.yml

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,60 @@
1-
name: CI
1+
name: Build and test
22

33
on:
44
pull_request:
55
workflow_dispatch:
66

77
env:
8+
DISTRIBUTION: temurin
9+
JVM_TYPE: jre
10+
JVM_VERSION: 17
811
REGISTRY: ghcr.io
912

1013
jobs:
11-
create-short-sha:
12-
name: Create short commit sha
14+
build-vars:
15+
name: Create build variables
1316
runs-on: ubuntu-latest
1417
outputs:
15-
short-sha: ${{ steps.short-sha-output.outputs.short-sha }}
18+
distribution: ${{ steps.build-vars.outputs.distribution }}
19+
jvm-type: ${{ steps.build-vars.outputs.jvm-type }}
20+
jvm-version: ${{ steps.build-vars.outputs.jvm-version }}
21+
registry: ${{ steps.build-vars.outputs.registry }}
1622
steps:
17-
- name: Create short commit sha output
18-
id: short-sha-output
19-
run: echo "short-sha=`echo $GITHUB_SHA | cut -c1-8`" >> $GITHUB_OUTPUT
23+
- id: build-vars
24+
name: Create build variables
25+
run: |
26+
echo "distribution=$DISTRIBUTION" >> $GITHUB_OUTPUT
27+
echo "jvm-type=$JVM_TYPE" >> $GITHUB_OUTPUT
28+
echo "jvm-version=$JVM_VERSION" >> $GITHUB_OUTPUT
29+
echo "registry=$REGISTRY" >> $GITHUB_OUTPUT
30+
31+
sha-tag:
32+
name: Create sha docker tag
33+
uses: ./.github/workflows/create-sha-docker-tag.yml
34+
needs: build-vars
35+
with:
36+
jvm-type: ${{ needs.build-vars.outputs.jvm-type }}
37+
jvm-version: ${{ needs.build-vars.outputs.jvm-version }}
2038

2139
build-and-deploy:
22-
name: Build and push Java ${{ matrix.jvmVersion }} ${{ matrix.jvmType }} image to registry
23-
needs: create-short-sha
24-
runs-on: ubuntu-latest
25-
env:
26-
TAG: ${{ needs.create-short-sha.outputs.short-sha }}-${{ matrix.jvmType }}${{ matrix.jvmVersion }}
27-
strategy:
28-
matrix:
29-
jvmType: [jre]
30-
jvmVersion: [17]
31-
steps:
32-
- name: Checkout
33-
uses: actions/checkout@v4
34-
with:
35-
ref: ${{ github.event.workflow_run.head_branch }}
36-
- name: Set up JDK ${{ matrix.jvmVersion }}
37-
uses: actions/setup-java@v4
38-
with:
39-
java-version: ${{ matrix.jvmVersion }}
40-
distribution: temurin
41-
- name: Build and deploy OCI image
42-
run: >
43-
./gradlew bootBuildImage
44-
-PjvmType=${{ matrix.jvmType }}
45-
-PjdkVersion=${{ matrix.jvmVersion }}
46-
-PdockerUsername=${{ github.actor }}
47-
-PdockerPassword=${{ secrets.GITHUB_TOKEN }}
48-
--imageName=$REGISTRY/$GITHUB_REPOSITORY:$TAG
49-
--publishImage
40+
name: Build and deploy OCI image
41+
uses: ./.github/workflows/build-and-deploy-image.yml
42+
needs:
43+
- build-vars
44+
- sha-tag
45+
with:
46+
image-name: ${{ github.repository }}:${{ needs.sha-tag.outputs.tag }}
47+
registry: ${{ needs.build-vars.outputs.registry }}
48+
5049
integration-test:
51-
name: Verify Java ${{ matrix.jvmVersion }} ${{ matrix.jvmType }} image with ${{ matrix.backend }}
50+
name: Verify OCI image with ${{ matrix.backend }}
5251
needs:
53-
- create-short-sha
52+
- build-vars
5453
- build-and-deploy
5554
runs-on: ubuntu-latest
56-
env:
57-
TAG: ${{ needs.create-short-sha.outputs.short-sha }}-${{ matrix.jvmType }}${{ matrix.jvmVersion }}
5855
strategy:
5956
fail-fast: false
6057
matrix:
61-
jvmType: [jre]
62-
jvmVersion: [17]
6358
backend: [
6459
aws-param-store,
6560
aws-s3,
@@ -78,17 +73,20 @@ jobs:
7873
steps:
7974
- name: Checkout
8075
uses: actions/checkout@v4
81-
with:
82-
ref: ${{ github.event.workflow_run.head_branch }}
83-
- name: Set up JDK 17
76+
77+
- name: Set up JDK ${{ needs.build-vars.outputs.jvm-version }}
8478
uses: actions/setup-java@v4
8579
with:
86-
java-version: 17
87-
distribution: temurin
80+
distribution: ${{ needs.build-vars.outputs.distribution }}
81+
java-version: ${{ needs.build-vars.outputs.jvm-version }}
82+
83+
- name: Setup Gradle
84+
uses: gradle/actions/setup-gradle@v3
85+
8886
- name: Test with ${{ matrix.backend }}
8987
run: >
9088
./gradlew test -i
9189
-PtestFilter=${{ matrix.backend }}
92-
-PimageRegistry=${{ env.REGISTRY }}
93-
-PimageTag=${{ env.TAG }}
94-
-PjdkVersion=${{ matrix.jvmVersion }}
90+
-PimageRegistry=${{ needs.build-vars.outputs.registry }}
91+
-PjdkVersion=${{ needs.build-vars.outputs.jvm-version }}
92+
-PimageTag=${{ needs.sha-tag.outputs.tag }}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Find build and latest versions of cloud config
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
distribution:
7+
description: JVM distribution to run
8+
type: string
9+
default: temurin
10+
java-version:
11+
description: JVM version to run
12+
type: string
13+
default: 17
14+
outputs:
15+
build:
16+
description: Current build version of cloud config
17+
value: ${{ jobs.cloud-config-versions.outputs.build }}
18+
latest:
19+
description: Latest version of cloud config
20+
value: ${{ jobs.cloud-config-versions.outputs.latest }}
21+
22+
jobs:
23+
cloud-config-versions:
24+
name: Create Cloud Config Versions
25+
runs-on: ubuntu-latest
26+
outputs:
27+
build: ${{ steps.vars.outputs.build }}
28+
latest: ${{ steps.vars.outputs.latest }}
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Set up JDK ${{ inputs.java-version }}
34+
uses: actions/setup-java@v4
35+
with:
36+
distribution: ${{ inputs.distribution }}
37+
java-version: ${{ inputs.java-version }}
38+
39+
- name: Setup Gradle
40+
uses: gradle/actions/setup-gradle@v3
41+
42+
- name: Set cloud config versions
43+
id: vars
44+
run: |
45+
echo "latest=`curl -s https://search.maven.org/solrsearch/select\?q\=g:%22org.springframework.cloud%22%20AND%20a:%22spring-cloud-config-server%22 | jq -r '.response.docs[0].latestVersion'`" >> $GITHUB_OUTPUT
46+
echo "build=`./gradlew dependencyInsight --dependency org.springframework.cloud:spring-cloud-config-server | grep 'org.springframework.cloud:spring-cloud-config-server:' | tail -1 | cut -d ':' -f 3-`" >> $GITHUB_OUTPUT
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Create sha docker tag
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
jvm-type:
7+
description: JVM type for output image
8+
type: string
9+
default: jre
10+
jvm-version:
11+
description: JVM version for output image
12+
type: string
13+
default: 17
14+
outputs:
15+
tag:
16+
description: Docker tag with sha of commit
17+
value: ${{ jobs.create-sha-docker-tag.outputs.tag }}
18+
19+
jobs:
20+
jvm-tag:
21+
uses: ./.github/workflows/generate-jvm-tag.yml
22+
with:
23+
jvm-type: ${{ inputs.jvm-type }}
24+
jvm-version: ${{ inputs.jvm-version }}
25+
26+
create-sha-docker-tag:
27+
name: Create sha docker tag
28+
needs: jvm-tag
29+
runs-on: ubuntu-latest
30+
outputs:
31+
tag: ${{ steps.vars.outputs.tag }}
32+
steps:
33+
- name: Build sha docker tag
34+
id: vars
35+
run: echo "tag=`echo $GITHUB_SHA | cut -c1-7`-${{ needs.jvm-tag.outputs.jvm-tag }}" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)