forked from cmuriukin/docker-java-test-app
-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (57 loc) · 1.67 KB
/
main.yml
File metadata and controls
66 lines (57 loc) · 1.67 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
name: docker-java-test-app
on:
push:
branches: [main]
jobs:
build_and_test:
runs-on: ubuntu-latest
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 5s
--health-retries 3
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3.3.0
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 14
- name: Cache maven project
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashfiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and test project with maven
run: mvn -B package --file pom.xml
publish-job:
runs-on: ubuntu-latest
needs: [build_and_test]
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/setup-java@v1
with:
java-version: 14
- run: mvn -B package --file pom.xml -DskipTests
- run: mkdir staging && cp target/*jar-with-dependencies.jar staging
- uses: actions/upload-artifact@v3.1.2
with:
name: Package
path: staging
build-docker-image:
name: publish to Docker Hub
runs-on: ubuntu-latest
needs: [build_and_test]
steps:
- uses: actions/checkout@v2
- name: Login to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build container image
run: docker build -t ${{ secrets.DOCKER_REPO }}:latest .
- name: Publish Docker image
run: docker push ${{ secrets.DOCKER_REPO }}