Skip to content

Commit

Permalink
don't push to :latest for every build
Browse files Browse the repository at this point in the history
  • Loading branch information
nisrael committed Jun 3, 2024
1 parent 199e7a8 commit 695c8a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,25 @@ jobs:
./mvnw install \
-B --no-transfer-progress --file pom.xml \
-D docker.app.image.registry=${{ env.DOCKER_IMAGE_REGISTRY }} \
-D docker.app.image.sha=${GITHUB_SHA::7} \
-P exec.docker.image \
-am -pl addondemo.app.image
- name: Format branch name for Docker tag
if: github.ref != 'refs/heads/main'
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
FORMATTED_BRANCH_NAME=${BRANCH_NAME//\//-}
echo "FORMATTED_BRANCH_NAME=$FORMATTED_BRANCH_NAME" >> $GITHUB_ENV
- name: Build and push image for all branches except main
if: github.ref != 'refs/heads/main'
run: |
./mvnw install \
-B --no-transfer-progress --file pom.xml \
-D docker.app.image.registry=${{ env.DOCKER_IMAGE_REGISTRY }} \
-D docker.app.image.tag=${GITHUB_SHA::7} \
-D docker.app.image.tag=${{ env.FORMATTED_BRANCH_NAME }} \
-D docker.app.image.sha=${GITHUB_SHA::7} \
-P exec.docker.image \
-am -pl addondemo.app.image
Expand Down
6 changes: 4 additions & 2 deletions addondemo.app.image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<to>
<image>${docker.app.image.registry}/app</image>
<!-- prevent jib to push to :latest by specifying a tag in the image -->
<image>${docker.app.image}</image>
<!-- the tags here are *additional* tags -->
<tags>
<tag>${docker.app.image.tag}</tag>
<tag>${docker.app.image.sha}</tag>
</tags>
</to>
<from>
Expand Down
3 changes: 3 additions & 0 deletions addondemo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
<master_plugin_jib_version>3.4.3</master_plugin_jib_version>
<!-- build target (push) -->
<docker.app.image.registry>localhost:5000</docker.app.image.registry> <!-- set a desired registry before using profile exec.docker.image (e.g. registry.hub.docker.com/yourusername) -->
<docker.app.image.name>app</docker.app.image.name>
<docker.app.image.tag>24.1-latest</docker.app.image.tag>
<docker.app.image>${docker.app.image.registry}/${docker.app.image.name}:${docker.app.image.tag}</docker.app.image>
<docker.app.image.sha>${maven.build.timestamp}</docker.app.image.sha>
<!-- java source image (pull) -->
<docker.java.image>registry-1.docker.io/library/eclipse-temurin:17-jdk-jammy</docker.java.image>
<sxda.addon.version>24.1.3</sxda.addon.version>
Expand Down

0 comments on commit 695c8a9

Please sign in to comment.