Skip to content

Commit

Permalink
ci: aligned workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
vondacho committed Jun 8, 2024
1 parent 0841ed8 commit c0fffd9
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 100 deletions.
51 changes: 26 additions & 25 deletions .github/workflows/ci-customer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
push-to-registry: true
51 changes: 26 additions & 25 deletions .github/workflows/ci-designer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
push-to-registry: true
51 changes: 26 additions & 25 deletions .github/workflows/ci-invoicing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
push-to-registry: true
51 changes: 26 additions & 25 deletions .github/workflows/ci-shopping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
push-to-registry: true

0 comments on commit c0fffd9

Please sign in to comment.