Skip to content

ci: fix pipeline

ci: fix pipeline #6

Workflow file for this run

name: CI devops 2023
on:
#to begin you want to launch this job in main and develop
push:
branches: #TODO
pull_request:
jobs:
test-backend:
runs-on: ubuntu-22.04
steps:
#checkout your github code using actions/[email protected]
- uses: actions/[email protected]
#do the same with another action (actions/setup-java@v3) that enable to setup jdk 17
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: "temurin" # See 'Supported distributions' for available options
java-version: "21"
#finally build your app with the latest command
- name: Build and test with Maven
working-directory: backend-api
run: mvn clean verify
- name: Send to sonarcloud for static analysis
working-directory: backend-api
run: mvn -B verify sonar:sonar -Dsonar.projectKey=${SONAR_PROJECT_KEY} -Dsonar.organization=${SONAR_ORGANIZATION} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} --file ./simple-api/pom.xml
# define job to build and publish docker image
build-and-push-docker-image:
needs: test-backend
# run only when code is compiling and tests are passing
runs-on: ubuntu-22.04
# steps to perform in job
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build image and push backend
uses: docker/build-push-action@v3
with:
# relative path to the place where source code with Dockerfile is located
file: ./Dockerfile.api
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{secrets.DOCKERHUB_USERNAME}}/api:latest
- name: Build image and push database
uses: docker/build-push-action@v3
with:
# relative path to the place where source code with Dockerfile is located
file: ./Dockerfile.db
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{secrets.DOCKERHUB_USERNAME}}/database:latest
- name: Build image and push httpd
uses: docker/build-push-action@v3
with:
# relative path to the place where source code with Dockerfile is located
file: ./Dockerfile.http
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{secrets.DOCKERHUB_USERNAME}}/httpd:latest