👷 integrate all workflows into one pipeline #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | ||
build_publish_docker: | ||
name: Build&Publish - Util Docker images | ||
runs-on: ubuntu-latest | ||
needs: build_java | ||
Check failure on line 32 in .github/workflows/ci-cd.yml GitHub Actions / CI/CD PipelineInvalid workflow file
|
||
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_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 |