-
Notifications
You must be signed in to change notification settings - Fork 759
74 lines (70 loc) · 2.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
name: Maven GitHub Actions Sample
on: [push]
jobs:
compile:
runs-on: ubuntu-20.04
strategy:
matrix:
java: [ 11, 12, 13 ]
name: Java ${{ matrix.java }} compile
steps:
- name: Checkout Source Code
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-package: jdk
java-version: ${{ matrix.java }}
- name: Compile the Project
working-directory: github-actions-java-maven
run: mvn -B compile
build:
runs-on: ubuntu-20.04
needs: compile
name: Build the Maven Project
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
java-package: jdk
- name: Build and test project
working-directory: github-actions-java-maven
run: mvn -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-20.04
needs: build
name: Build Docker Container and Deploy to Kubernetes
steps:
- uses: actions/checkout@v2
- 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)"