-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.txt
More file actions
78 lines (68 loc) · 2.78 KB
/
main.txt
File metadata and controls
78 lines (68 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: CI devops 2024
on:
#to begin you want to launch this job in main and develop
push:
branches:
- main
- develop
pull_request:
jobs:
test-backend:
runs-on: ubuntu-22.04
steps:
#checkout your github code using actions/checkout@v2.5.0
- uses: actions/checkout@v2.5.0
#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@v3
with:
distribution: 'temurin'
java-version: '17'
#finally build your app with the latest command
- name: Build and test with Maven
run: mvn -B verify sonar:sonar -Dsonar.projectKey=devons_devops -Dsonar.organization=devons -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} --file ./API/simple-api-student-main/pom.xml
#run: mvn clean install --file ./API/simple-api-student-main/pom.xml
env:
JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.11-9/x64
JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.11-9/x64
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build-and-push-docker-image:
needs: test-backend
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2.5.0
- name: Login to DockerHub
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build image and push backend
uses: docker/build-push-action@v3
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
with:
context: ./API/simple-api-student-main
tags: ${{ secrets.DOCKER_USERNAME }}/my-backend-app:backend-latest
push: ${{ github.ref == 'refs/heads/main' }}
#push: True
- name: Build image and push database
uses: docker/build-push-action@v3
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
with:
tags: ${{ secrets.DOCKER_USERNAME }}/my-postgres-db:database-latest
push: True
#push: ${{ github.ref == 'refs/heads/main' }}
- name: Build image and push httpd
uses: docker/build-push-action@v3
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
with:
context: ./http
tags: ${{ secrets.DOCKER_USERNAME }}/my-apache2:httpd-latest
push: True
#push: ${{ github.ref == 'refs/heads/main' }}