Skip to content

Commit e192749

Browse files
committed
wip: docker metadata and other workflow improvements
1 parent 25efd51 commit e192749

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

.github/workflows/maven-bump-push-dockerhub.yml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,11 @@ jobs:
6060
env:
6161
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6262
run: |
63-
REPO_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
64-
6563
mvn verify -B -P prod,coverage "-Dstyle.color=always" \
6664
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
6765
-Dsonar.host.url="https://sonarcloud.io" \
68-
-Dsonar.organization=soat-tech-challenge \
69-
-Dsonar.projectKey=soat-tech-challenge_$REPO_NAME
66+
-Dsonar.organization=${{ github.repository_owner }} \
67+
-Dsonar.projectKey=${{ github.repository_owner }}_${{ github.event.repository.name }}
7068
7169
- name: Commit, Tag and Push New Version
7270
id: bump
@@ -75,14 +73,21 @@ jobs:
7573
commit-message: "[skip ci] Bump version to"
7674
version: ${{ steps.semver.outputs.nextStrict }}
7775

78-
- name: Upload Artifact
76+
- name: Upload JAR Artifact
7977
id: upload
8078
uses: actions/upload-artifact@v4
8179
with:
82-
name: app-${{ steps.semver.outputs.nextStrict }}
83-
path: target/app.jar
80+
name: ${{ github.event.repository.name }}-${{ steps.semver.outputs.nextStrict }}
81+
path: target/*.jar
8482
if-no-files-found: error
8583

84+
- name: Upload Coverage Report Artifact
85+
id: upload
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: ${{ github.event.repository.name }}-${{ steps.semver.outputs.nextStrict }}-coverage-report
89+
path: target/site/jacoco/*
90+
8691
docker:
8792
name: Docker Build and Push
8893
if: ${{ inputs.docker == true || inputs.docker == 'true' }}
@@ -96,22 +101,40 @@ jobs:
96101
- name: Checkout
97102
uses: actions/checkout@v3
98103

99-
- name: Download Artifact
104+
- name: Download JAR Artifact
100105
uses: actions/download-artifact@v4
101106
with:
102107
name: ${{ needs.build.outputs.artifact_name }}
103-
path: target/app.jar
108+
path: target/*.jar
104109

105110
- name: Login to Docker Hub
106111
uses: docker/login-action@v3
107112
with:
108113
username: ${{ inputs.dockerhub_username }}
109114
password: ${{ secrets.DOCKERHUB_TOKEN }}
110115

116+
- name: Get Docker Metadata
117+
id: meta
118+
uses: docker/metadata-action@v3
119+
with:
120+
images: ${{ inputs.dockerhub_username }}/${{ github.event.repository.name }}
121+
labels: |
122+
org.opencontainers.image.authors=${{ github.event.repository.owner.html_url }}#group-members
123+
org.opencontainers.image.title=${{ github.event.repository.name }}
124+
org.opencontainers.image.description=${{ github.event.repository.description }}
125+
org.opencontainers.image.url=https://hub.docker.com/r/${{ inputs.dockerhub_username }}/${{ github.event.repository.name }}
126+
org.opencontainers.image.documentation=${{ github.event.repository.html_url }}/wiki
127+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
128+
org.opencontainers.image.version=${{ needs.build.outputs.new_tag }}
129+
org.opencontainers.image.created=${{ github.event.repository.pushed_at }}
130+
org.opencontainers.image.revision=${{ github.sha }}
131+
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
132+
111133
- name: Build and push image
112134
id: docker_build_push
113135
uses: docker/build-push-action@v5
114136
with:
115137
context: .
116138
push: true
117-
tags: ${{ inputs.image_name }}:${{ needs.build.outputs.new_tag }},${{ inputs.image_name }}:latest
139+
tags: ${{ steps.meta.outputs.tags }}
140+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)