From c0fffd9e81e4a5815460c6c79c1cbe9a59accdca Mon Sep 17 00:00:00 2001 From: Olivier von Dach Date: Sat, 8 Jun 2024 15:19:07 +0200 Subject: [PATCH] ci: aligned workflows --- .github/workflows/ci-customer.yml | 51 +++++++++++++++--------------- .github/workflows/ci-designer.yml | 51 +++++++++++++++--------------- .github/workflows/ci-invoicing.yml | 51 +++++++++++++++--------------- .github/workflows/ci-shopping.yml | 51 +++++++++++++++--------------- 4 files changed, 104 insertions(+), 100 deletions(-) diff --git a/.github/workflows/ci-customer.yml b/.github/workflows/ci-customer.yml index 08c73ec..5330024 100644 --- a/.github/workflows/ci-customer.yml +++ b/.github/workflows/ci-customer.yml @@ -5,14 +5,15 @@ on: paths: - 'pta-customer/**' tags: - - 'pta-customer/v*.*.*' + - 'v*.*.*-pta-customer' branches: - 'main' workflow_dispatch: env: - REGISTRY: ghcr.io - IMAGE_NAME: pta-customer + MODULE_NAME: pta-customer + DOCKER_REGISTRY: ghcr.io + DOCKER_IMAGE_NAME: ${{ github.repository }}/pta-customer jobs: build: @@ -29,48 +30,48 @@ jobs: uses: actions/checkout@v4 - name: Set up JDK 21 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' - cache: maven - cache-dependency-path: 'pta-customer/pom.xml' + cache: 'maven' - name: Build with Maven - run: mvn -B package --file pta-customer/pom.xml + run: mvn -B package --file ${{ env.MODULE_NAME }}/pom.xml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Log in to the Container registry - if: startsWith(github.ref, 'refs/tags/pta-customer/') - uses: docker/login-action@v2 + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') + uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ${{ env.DOCKER_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - if: startsWith(github.ref, 'refs/tags/pta-customer/') - id: meta - uses: docker/metadata-action@v4 + - name: Sanitize tag name + uses: actions/github-script@v7 + id: sanitized_tag with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: ${{ github.ref }} + result-encoding: string + script: return '${{ github.ref }}'.replace('refs/tags/', '').replace('-${{ env.MODULE_NAME }}', '').trim() - name: Build and push Docker image - if: startsWith(github.ref, 'refs/tags/pta-customer/') - uses: docker/build-push-action@v4 + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') + id: push + uses: docker/build-push-action@v5 with: - context: . - file: ./pta-customer/Dockerfile + context: '/home/runner/work/pt-agency/pt-agency/${{ env.MODULE_NAME }}' + file: '${{ env.MODULE_NAME }}/src/main/docker/Dockerfile.jvm' push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: | + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:latest + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.sanitized_tag.outputs.result }} - name: Generate artifact attestation - if: startsWith(github.ref, 'refs/tags/pta-customer/') + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') uses: actions/attest-build-provenance@v1 with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-name: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME}} subject-digest: ${{ steps.push.outputs.digest }} - push-to-registry: true \ No newline at end of file + push-to-registry: true diff --git a/.github/workflows/ci-designer.yml b/.github/workflows/ci-designer.yml index 4bab4fc..0416198 100644 --- a/.github/workflows/ci-designer.yml +++ b/.github/workflows/ci-designer.yml @@ -5,14 +5,15 @@ on: paths: - 'pta-designer/**' tags: - - 'pta-designer/v*.*.*' + - 'v*.*.*-pta-designer' branches: - 'main' workflow_dispatch: env: - REGISTRY: ghcr.io - IMAGE_NAME: pta-designer + MODULE_NAME: pta-designer + DOCKER_REGISTRY: ghcr.io + DOCKER_IMAGE_NAME: ${{ github.repository }}/pta-designer jobs: build: @@ -29,48 +30,48 @@ jobs: uses: actions/checkout@v4 - name: Set up JDK 21 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' - cache: maven - cache-dependency-path: 'pta-designer/pom.xml' + cache: 'maven' - name: Build with Maven - run: mvn -B package --file pta-designer/pom.xml + run: mvn -B package --file ${{ env.MODULE_NAME }}/pom.xml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Log in to the Container registry - if: startsWith(github.ref, 'refs/tags/pta-designer/') - uses: docker/login-action@v2 + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') + uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ${{ env.DOCKER_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - if: startsWith(github.ref, 'refs/tags/pta-designer/') - id: meta - uses: docker/metadata-action@v4 + - name: Sanitize tag name + uses: actions/github-script@v7 + id: sanitized_tag with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: ${{ github.ref }} + result-encoding: string + script: return '${{ github.ref }}'.replace('refs/tags/', '').replace('-${{ env.MODULE_NAME }}', '').trim() - name: Build and push Docker image - if: startsWith(github.ref, 'refs/tags/pta-designer/') - uses: docker/build-push-action@v4 + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') + id: push + uses: docker/build-push-action@v5 with: - context: . - file: ./pta-designer/Dockerfile + context: '/home/runner/work/pt-agency/pt-agency/${{ env.MODULE_NAME }}' + file: '${{ env.MODULE_NAME }}/src/main/docker/Dockerfile.jvm' push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: | + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:latest + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.sanitized_tag.outputs.result }} - name: Generate artifact attestation - if: startsWith(github.ref, 'refs/tags/pta-designer/') + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') uses: actions/attest-build-provenance@v1 with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-name: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME}} subject-digest: ${{ steps.push.outputs.digest }} - push-to-registry: true \ No newline at end of file + push-to-registry: true diff --git a/.github/workflows/ci-invoicing.yml b/.github/workflows/ci-invoicing.yml index 3c67439..c55f78a 100644 --- a/.github/workflows/ci-invoicing.yml +++ b/.github/workflows/ci-invoicing.yml @@ -5,14 +5,15 @@ on: paths: - 'pta-invoicing/**' tags: - - 'pta-invoicing/v*.*.*' + - 'v*.*.*-pta-invoicing' branches: - 'main' workflow_dispatch: env: - REGISTRY: ghcr.io - IMAGE_NAME: pta-invoicing + MODULE_NAME: pta-invoicing + DOCKER_REGISTRY: ghcr.io + DOCKER_IMAGE_NAME: ${{ github.repository }}/pta-invoicing jobs: build: @@ -29,48 +30,48 @@ jobs: uses: actions/checkout@v4 - name: Set up JDK 21 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' - cache: maven - cache-dependency-path: 'pta-invoicing/pom.xml' + cache: 'maven' - name: Build with Maven - run: mvn -B package --file pta-invoicing/pom.xml + run: mvn -B package --file ${{ env.MODULE_NAME }}/pom.xml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Log in to the Container registry - if: startsWith(github.ref, 'refs/tags/pta-invoicing/') - uses: docker/login-action@v2 + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') + uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ${{ env.DOCKER_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - if: startsWith(github.ref, 'refs/tags/pta-invoicing/') - id: meta - uses: docker/metadata-action@v4 + - name: Sanitize tag name + uses: actions/github-script@v7 + id: sanitized_tag with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: ${{ github.ref }} + result-encoding: string + script: return '${{ github.ref }}'.replace('refs/tags/', '').replace('-${{ env.MODULE_NAME }}', '').trim() - name: Build and push Docker image - if: startsWith(github.ref, 'refs/tags/pta-invoicing/') - uses: docker/build-push-action@v4 + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') + id: push + uses: docker/build-push-action@v5 with: - context: . - file: ./pta-invoicing/Dockerfile + context: '/home/runner/work/pt-agency/pt-agency/${{ env.MODULE_NAME }}' + file: '${{ env.MODULE_NAME }}/src/main/docker/Dockerfile.jvm' push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: | + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:latest + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.sanitized_tag.outputs.result }} - name: Generate artifact attestation - if: startsWith(github.ref, 'refs/tags/pta-invoicing/') + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') uses: actions/attest-build-provenance@v1 with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-name: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME}} subject-digest: ${{ steps.push.outputs.digest }} - push-to-registry: true \ No newline at end of file + push-to-registry: true diff --git a/.github/workflows/ci-shopping.yml b/.github/workflows/ci-shopping.yml index 74e2057..9bfbac7 100644 --- a/.github/workflows/ci-shopping.yml +++ b/.github/workflows/ci-shopping.yml @@ -5,14 +5,15 @@ on: paths: - 'pta-shopping/**' tags: - - 'pta-shopping/v*.*.*' + - 'v*.*.*-pta-shopping' branches: - 'main' workflow_dispatch: env: - REGISTRY: ghcr.io - IMAGE_NAME: pta-shopping + MODULE_NAME: pta-shopping + DOCKER_REGISTRY: ghcr.io + DOCKER_IMAGE_NAME: ${{ github.repository }}/pta-shopping jobs: build: @@ -29,48 +30,48 @@ jobs: uses: actions/checkout@v4 - name: Set up JDK 21 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' - cache: maven - cache-dependency-path: 'pta-shopping/pom.xml' + cache: 'maven' - name: Build with Maven - run: mvn -B package --file pta-shopping/pom.xml + run: mvn -B package --file ${{ env.MODULE_NAME }}/pom.xml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Log in to the Container registry - if: startsWith(github.ref, 'refs/tags/pta-shopping/') - uses: docker/login-action@v2 + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') + uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ${{ env.DOCKER_REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - if: startsWith(github.ref, 'refs/tags/pta-shopping/') - id: meta - uses: docker/metadata-action@v4 + - name: Sanitize tag name + uses: actions/github-script@v7 + id: sanitized_tag with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: ${{ github.ref }} + result-encoding: string + script: return '${{ github.ref }}'.replace('refs/tags/', '').replace('-${{ env.MODULE_NAME }}', '').trim() - name: Build and push Docker image - if: startsWith(github.ref, 'refs/tags/pta-shopping/') - uses: docker/build-push-action@v4 + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') + id: push + uses: docker/build-push-action@v5 with: - context: . - file: ./pta-shopping/Dockerfile + context: '/home/runner/work/pt-agency/pt-agency/${{ env.MODULE_NAME }}' + file: '${{ env.MODULE_NAME }}/src/main/docker/Dockerfile.jvm' push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: | + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:latest + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.sanitized_tag.outputs.result }} - name: Generate artifact attestation - if: startsWith(github.ref, 'refs/tags/pta-shopping/') + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ env.MODULE_NAME }}') uses: actions/attest-build-provenance@v1 with: - subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-name: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME}} subject-digest: ${{ steps.push.outputs.digest }} - push-to-registry: true \ No newline at end of file + push-to-registry: true