Skip to content

CI/CD Pipeline

CI/CD Pipeline #5

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: ['main']
jobs:
build_test_java:
name: Build Java services
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@v4.0.2
build_publish_docker:
name: Build&Publish - Util Docker images
runs-on: ubuntu-latest
needs: build_test_java
strategy:
matrix:
image:
- prometheus
- grafana
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
file: ./docker/${{ matrix.image }}/Dockerfile
push: true
tags: ghcr.io/tobias-pe/microservices_energyefficiency/${{ matrix.image }}:latest, ghcr.io/tobias-pe/microservices_energyefficiency/${{ matrix.image }}:${{ github.run_id }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
build_publish_spring_boot:
name: Build&Publish - Spring Boot Docker images
runs-on: ubuntu-latest
needs: build_test_java
strategy:
matrix:
image:
- gateway
- servicediscovery
- userservice
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Make Maven Wrapper executable
if: contains(matrix.os, 'win') == false
run: chmod +x ./mvnw
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set VERSION environment variable
run: |
echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -pl ${{ matrix.image }})" >> $GITHUB_ENV
- name: Docker Build-Tag-Push
run: |
./mvnw spring-boot:build-image -pl ${{ matrix.image }} -am
docker tag ${{ matrix.image }}:${{ env.VERSION }} ghcr.io/tobias-pe/microservices_energyefficiency/${{ matrix.image }}:${{ github.run_id }}
docker tag ${{ matrix.image }}:${{ env.VERSION }} ghcr.io/tobias-pe/microservices_energyefficiency/${{ matrix.image }}:${{ env.VERSION }}
docker tag ${{ matrix.image }}:${{ env.VERSION }} ghcr.io/tobias-pe/microservices_energyefficiency/${{ matrix.image }}:latest
docker push ghcr.io/tobias-pe/microservices_energyefficiency/${{ matrix.image }}:latest