-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (84 loc) · 2.39 KB
/
pipeline-backend.yaml
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Backend Pipeline
on:
push:
branches:
- master
paths:
- 'rent-a-tool/**'
- 'docker/backend/**'
- 'docker-compose.yaml'
- '.github/workflows/pipeline-backend.yaml'
jobs:
compile:
runs-on: self-hosted
name: Compile project
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
- name: Compile project
run: |
cd rent-a-tool
chmod +x mvnw
./mvnw clean compile
build:
runs-on: self-hosted
name: Build backend
needs: [compile]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
- name: Build project
run: |
cd rent-a-tool
chmod +x mvnw
./mvnw clean package -DskipTests
build-docker-image:
runs-on: self-hosted
name: Build Docker image
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'corretto'
- name: Extract project version
id: extract_version
run: |
cd rent-a-tool
chmod +x mvnw
echo "VERSION=$(./mvnw -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push to DockerHub
uses: docker/build-push-action@v5
with:
context: rent-a-tool
file: docker/backend/Dockerfile
push: true
platforms: linux/amd64
tags: ${{ secrets.DOCKERHUB_USERNAME }}/rent-a-tool-backend:${{ steps.extract_version.outputs.VERSION }},${{ secrets.DOCKERHUB_USERNAME }}/rent-a-tool-backend:latest
build-args: |
PROFILE=prod
APP_VERSION=${{ steps.extract_version.outputs.VERSION }}