File tree 3 files changed +100
-0
lines changed 3 files changed +100
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : CI/CD pipeline for successful merge
2
+ on :
3
+ push :
4
+ branches :
5
+ - master
6
+ workflow_dispatch :
7
+
8
+ jobs :
9
+ build :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Checkout code
13
+ uses : actions/checkout@v4
14
+
15
+ - name : Setup java
16
+ uses : actions/setup-java@v4
17
+ with :
18
+ java-version : ' 21'
19
+ cache : ' maven'
20
+ distribution : ' corretto'
21
+
22
+ - name : Add executable permissions
23
+ run : chmod a+x mvnw
24
+
25
+ - name : Maven install dependencies
26
+ run : ./mvnw clean install package
27
+
28
+ - name : Upload JAR artifact
29
+ uses : actions/upload-artifact@v4
30
+ with :
31
+ name : app-protector
32
+ path : ./target/*.jar
33
+
34
+ - name : Login to Docker Hub
35
+ uses : docker/login-action@v3
36
+ with :
37
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
38
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
39
+
40
+ - name : Docker Build and Push
41
+ uses : docker/build-push-action@v6
42
+ with :
43
+ context : .
44
+ push : true
45
+ tags : |
46
+ ${{ secrets.DOCKERHUB_USERNAME }}/apiprotector:${{ github.sha }}
47
+
48
+ - name : Update CICD-VPS
49
+ env :
50
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
51
+ run : |
52
+ git config --global user.name 'Dawid Jabłoński'
53
+ git config --global user.email 'xederro@gmail.com'
54
+ git config --unset-all http.https://github.com/.extraheader
55
+ rm -rf .git
56
+ mkdir cicd
57
+ cd cicd
58
+ git clone "https://x-access-token:${{ secrets.TOKEN_VPS_REPO }}@github.com/xederro/CICD-VPS.git" --depth=1
59
+ cd CICD-VPS
60
+ sed -i 's|piachsecki/apiprotector:[0-9a-f]\{40\}|piachsecki/apiprotector:${{ github.sha }}|g' docker-stack.yml
61
+ git add .
62
+ git commit -m"API Protector Update: $(date)"
63
+ git push
Original file line number Diff line number Diff line change
1
+ name : CI/CD pipeline for successful merge
2
+ on :
3
+ workflow_dispatch :
4
+ pull_request :
5
+ branches :
6
+ - master
7
+
8
+ jobs :
9
+ build :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Checkout code
13
+ uses : actions/checkout@v4
14
+
15
+ - name : Setup java
16
+ uses : actions/setup-java@v4
17
+ with :
18
+ java-version : ' 21'
19
+ cache : ' maven'
20
+ distribution : ' corretto'
21
+
22
+ - name : Add executable permissions
23
+ run : chmod a+x mvnw
24
+
25
+ - name : Maven install dependencies
26
+ run : ./mvnw clean install package
27
+
28
+ - name : Upload JAR artifact
29
+ uses : actions/upload-artifact@v4
30
+ with :
31
+ name : app-protector
32
+ path : ./target/*.jar
Original file line number Diff line number Diff line change
1
+ FROM alpine/java:21-jdk@sha256:366ad7df4fafeca51290ccd7d6f046cf4bf3aa312e59bb191b4be543b39f25e2
2
+ RUN mkdir /app
3
+ WORKDIR /app
4
+ COPY ./target/apiprotector-0.0.1-SNAPSHOT.jar /app/app-protector.jar
5
+ CMD ["java" , "-jar" , "app-protector.jar" ]
You can’t perform that action at this time.
0 commit comments