|
| 1 | +name: Alarm Logger Docker Image CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "CSSTUDIO-2989" ] |
| 6 | + paths: services/alarm-logger/** |
| 7 | + tags: |
| 8 | + - '**' |
| 9 | + |
| 10 | +env: |
| 11 | + REGISTRY: ghcr.io |
| 12 | + IMAGE_NAME: ${{ github.repository }}/service-alarm-logger |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-server: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - name: Setup Maven and Java Action |
| 20 | + |
| 21 | + with: |
| 22 | + java-version: '17' |
| 23 | + maven-version: '3.9.6' |
| 24 | + - name: Build |
| 25 | + run: mvn --batch-mode install -DskipTests |
| 26 | + build-and-push-image: |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + packages: write |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + - name: Set up JDK 17 |
| 34 | + uses: actions/setup-java@v4 |
| 35 | + with: |
| 36 | + java-version: '17' |
| 37 | + distribution: 'temurin' |
| 38 | + cache: maven |
| 39 | + - name: Build with Maven |
| 40 | + run: mvn --batch-mode --update-snapshots package |
| 41 | + - name: Login to the registry |
| 42 | + uses: docker/login-action@v3 |
| 43 | + with: |
| 44 | + registry: ${{ env.REGISTRY }} |
| 45 | + username: ${{ github.actor }} |
| 46 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + - name: Extract meta-data for Docker |
| 48 | + id: meta |
| 49 | + uses: docker/metadata-action@v5 |
| 50 | + with: |
| 51 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 52 | + - name: Set up Docker Build |
| 53 | + uses: docker/setup-buildx-action@v3 |
| 54 | + - name: Build and publish the Docker image |
| 55 | + uses: docker/build-push-action@v5 |
| 56 | + with: |
| 57 | + context: services/alarm-logger |
| 58 | + push: true |
| 59 | + platforms: linux/amd64 |
| 60 | + tags: ${{ steps.meta.outputs.tags }} |
| 61 | + labels: ${{ steps.meta.outputs.labels }} |
| 62 | + cache-from: type=gha |
| 63 | + cache-to: type=gha,mode=max |
0 commit comments