-
Notifications
You must be signed in to change notification settings - Fork 759
76 lines (63 loc) · 2 KB
/
sampleJavaMavenProject.yml
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
name: Maven GitHub Actions Sample
on: [push]
jobs:
compile:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 21 ]
name: Java ${{ matrix.java }} compile
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-package: jdk
java-version: ${{ matrix.java }}
- name: Compile the Project
run: ./mvnw -f github-actions-java-maven/pom.xml -B compile
build:
runs-on: ubuntu-latest
needs: compile
name: Build the Maven Project
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '21'
java-package: jdk
cache: 'maven'
- name: Build and test project
run: ./mvnw -f github-actions-java-maven/pom.xml -B verify
- name: Upload Maven build artifact
uses: actions/upload-artifact@v2
with:
name: artifact.jar
path: github-actions-java-maven/target/github-actions-java-maven.jar
deploy:
runs-on: ubuntu-latest
needs: build
name: Build Docker Container and Deploy to Kubernetes
steps:
- uses: actions/checkout@v3
- name: Download Maven build artifact
uses: actions/download-artifact@v2
with:
name: artifact.jar
path: github-actions-java-maven/target
- name: Build Docker container
working-directory: github-actions-java-maven
run: |
docker build -t de.rieckpil.blog/github-actions-sample .
- name: Access secrets
env:
SUPER_SECRET: ${{ secrets.SUPER_SECRET }}
run: echo "Content of secret - $SUPER_SECRET"
- name: Push Docker images
run: echo "Pushing Docker image to Container Registry (e.g. ECR)"
- name: Deploy application
run: echo "Deploying application (e.g. Kubernetes)"