Skip to content

Commit

Permalink
ci: mises à jour
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerPixel committed Feb 6, 2024
1 parent 7e0bd9e commit 3170f43
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 48 deletions.
29 changes: 5 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,13 @@ name: Main pipeline
on:
#to begin you want to launch this job in main and develop
push:
branches:
- main
pull_request:
workflow_run:
workflows:
- "test"
types:
- completed

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=${{ vars.SONAR_PROJECT_KEY }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }}

# define job to build and publish docker image
build-and-push-docker-image-nightly:
needs: test-backend
Expand Down
32 changes: 8 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
on:
workflow_run:
workflows:
- "test.yml"
types:
- completed
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

name: Release pipeline
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=${{ vars.SONAR_PROJECT_KEY }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }}

# define job to build and publish docker image
build-and-push-docker-image-release:
needs: test-backend
Expand All @@ -49,15 +33,15 @@ jobs:
with:
# relative path to the place where source code with Dockerfile is located
file: ./Dockerfile.api
push: ${{ github.ref == 'refs/heads/main' }}
push: true
tags: ${{secrets.DOCKERHUB_USERNAME}}/api:${{ env.DOCKERHUB_TAG }}

- 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' }}
push: true
tags: ${{secrets.DOCKERHUB_USERNAME}}/database:${{ env.DOCKERHUB_TAG }}


Expand All @@ -66,5 +50,5 @@ jobs:
with:
# relative path to the place where source code with Dockerfile is located
file: ./Dockerfile.http
push: ${{ github.ref == 'refs/heads/main' }}
push: true
tags: ${{secrets.DOCKERHUB_USERNAME}}/httpd:${{ env.DOCKERHUB_TAG }}
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Tests
on:
push:
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=${{ vars.SONAR_PROJECT_KEY }} -Dsonar.organization=${{ vars.SONAR_ORGANIZATION }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }}

0 comments on commit 3170f43

Please sign in to comment.