Skip to content

Commit

Permalink
fix build via jib
Browse files Browse the repository at this point in the history
  • Loading branch information
nisrael committed Jun 2, 2024
1 parent 4ca72c3 commit afe382b
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 38 deletions.
30 changes: 2 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
name: build, package and deploy java parts
name: build and verify

on:
push:
branches: [ "main" ]
branches: [ "**" ]
pull_request:
branches: [ "main" ]

env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: ${{ github.repository }}
DOCKER_TAG_SHA: ${{ github.sha }}
DOCKER_TAG_REF: ${{ github.ref_name }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
Expand All @@ -24,14 +18,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Log into registry ${{ env.DOCKER_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-java@v4
with:
java-version: '17'
Expand All @@ -48,15 +34,3 @@ jobs:
uses: scacap/action-surefire-report@v1
with:
report_paths: '**/surefire-reports/TEST-*.xml, **/failsafe-reports/TEST-*.xml, **/karma-reports/**/test-*.xml'

- name: Build and push image except on PR
if: github.event_name != 'pull_request'
run: |
./mvnw install \
-B --no-transfer-progress --file pom.xml \
-P exec.docker.image \
-D docker.app.image.registry=${{ env.DOCKER_REGISTRY }} \
-D docker.app.image.name=${{ env.DOCKER_IMAGE_NAME }} \
-D docker.app.image.tag=${{ env.DOCKER_TAG_REF }} \
-D docker.app.image.tag2=${{ env.DOCKER_TAG_SHA }} \
-am -pl addondemo.app.image
64 changes: 64 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: build, package and deploy java parts

on:
push:
branches: [ "main" ]
workflow_dispatch:

env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_REGISTRY: ghcr.io/${{ github.repository }}
DOCKER_TAG_SHA: ${{ github.sha }}
DOCKER_TAG_REF: ${{ github.ref_name }}
DOCKER_REGISTRY_USERNAME: ${{ github.actor }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}


jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
checks: write
contents: read
packages: write

steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Log into registry ${{ env.DOCKER_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}


- name: Build zip with Maven and run tests
run: |
./mvnw verify \
-B --fail-at-end --no-transfer-progress --file pom.xml
- name: Publish Unit Test Report
if: success() || failure()
uses: scacap/action-surefire-report@v1
with:
report_paths: '**/surefire-reports/TEST-*.xml, **/failsafe-reports/TEST-*.xml, **/karma-reports/**/test-*.xml'

- name: Build and push image except on PR
if: github.event_name != 'pull_request'
run: |
./mvnw install \
-B --no-transfer-progress --file pom.xml \
-D docker.app.image.registry=${{ env.DOCKER_IMAGE_REGISTRY }} \
-P exec.docker.image \
-D docker.app.image.tag.ref=${{ env.DOCKER_TAG_REF }} \
-D docker.app.image.tag.sha=${{ env.DOCKER_TAG_SHA }} \
-am -pl addondemo.app.image
7 changes: 4 additions & 3 deletions addondemo.app.image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
<artifactId>jib-maven-plugin</artifactId>
<configuration>
<to>
<image>${docker.app.image.registry}/addondemo</image>
<image>${docker.app.image.registry}/app</image>
<tags>
<tag>${docker.app.image.tag}</tag>
<tag>${docker.app.image.tag2}</tag>
<tag>${docker.app.image.tag.latest}</tag>
<tag>${docker.app.image.tag.ref}</tag>
<tag>${docker.app.image.tag.sha}</tag>
</tags>
</to>
<from>
Expand Down
10 changes: 7 additions & 3 deletions addondemo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@
<master_npm_release_dependency_mapping>--mapping.0.regex=@eclipse-scout --mapping.0.version=${org.eclipse.scout.rt.version}</master_npm_release_dependency_mapping>

<!-- docker image build settings -->
<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.tag>24.1</docker.app.image.tag>
<docker.app.image.tag2>24.1-latest</docker.app.image.tag2>
<docker.app.image.name>24.1</docker.app.image.name>
<docker.app.image.tag.latest>24.1-latest</docker.app.image.tag.latest>
<docker.app.image.tag.ref>ref</docker.app.image.tag.ref>
<docker.app.image.tag.sha>sha</docker.app.image.tag.sha>
<!-- java source image (pull) -->
<docker.java.image.registry>docker.io</docker.java.image.registry>
<docker.java.image.name>eclipse-temurin</docker.java.image.name>
<docker.java.image.tag>17-jdk-jammy</docker.java.image.tag>
<docker.java.image>${docker.java.image.name}:${docker.java.image.tag}</docker.java.image>
<docker.java.image>${docker.java.image.registry}/${docker.java.image.name}:${docker.java.image.tag}</docker.java.image>
<sxda.addon.version>24.1.3</sxda.addon.version>
</properties>

Expand Down
6 changes: 2 additions & 4 deletions addondemo/run-configs/js build.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2">
<option name="RunConfigurationTask" enabled="true" run_configuration_name="pnpm-install" run_configuration_type="js.build_tools.npm" />
</method>
<method v="2" />
</configuration>
</component>
</component>

0 comments on commit afe382b

Please sign in to comment.