diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74ca939..14c41dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,19 +1,13 @@ -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: + build-and-verify: runs-on: ubuntu-latest permissions: @@ -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' @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..87413b6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,59 @@ +name: build and publish image + +on: + workflow_dispatch: + push: + branches: [ "main" ] + +env: + DOCKER_IMAGE_REGISTRY: ghcr.io/${{ github.repository }} + DOCKER_REGISTRY_USERNAME: ${{ github.actor }} + DOCKER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + + +jobs: + build-and-publish-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: Set DOCKER_APP_IMAGE for all branches except main + if: github.ref != 'refs/heads/main' + run: echo "DOCKER_APP_IMAGE=$(echo ${{ env.DOCKER_IMAGE_REGISTRY }}:${GITHUB_SHA::7})" >> $GITHUB_ENV + + - name: Set DOCKER_APP_IMAGE for main branch + if: github.ref == 'refs/heads/main' + run: echo "DOCKER_APP_IMAGE=$(echo ${{ env.DOCKER_IMAGE_REGISTRY }}:latest})" >> $GITHUB_ENV + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push image + run: | + ./mvnw install \ + -B --no-transfer-progress --file pom.xml \ + -D docker.app.image=${{ env.DOCKER_APP_IMAGE }} \ + -P exec.docker.image \ + -am -pl addondemo.app.image diff --git a/addondemo.app.image/pom.xml b/addondemo.app.image/pom.xml index 64b64d0..e283708 100644 --- a/addondemo.app.image/pom.xml +++ b/addondemo.app.image/pom.xml @@ -21,11 +21,7 @@ jib-maven-plugin - ${docker.app.image.registry}/addondemo - - ${docker.app.image.tag} - ${docker.app.image.tag2} - + ${docker.app.image} ${docker.java.image} diff --git a/addondemo/pom.xml b/addondemo/pom.xml index e52204b..ca4b159 100644 --- a/addondemo/pom.xml +++ b/addondemo/pom.xml @@ -18,14 +18,11 @@ --mapping.0.regex=@eclipse-scout --mapping.0.version=${org.eclipse.scout.rt.version} + 3.4.3 - localhost:5000 - 24.1 - 24.1-latest + localhost:5000/app - eclipse-temurin - 17-jdk-jammy - ${docker.java.image.name}:${docker.java.image.tag} + registry-1.docker.io/library/eclipse-temurin:17-jdk-jammy 24.1.3 diff --git a/addondemo/run-configs/js build.run.xml b/addondemo/run-configs/js build.run.xml index 5bb6630..bc47931 100644 --- a/addondemo/run-configs/js build.run.xml +++ b/addondemo/run-configs/js build.run.xml @@ -7,8 +7,6 @@ - - + - + \ No newline at end of file