forked from dhatanian/ticketmagpie
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (87 loc) · 2.86 KB
/
ci-workflow-java-maven.yml
File metadata and controls
108 lines (87 loc) · 2.86 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
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
98
99
100
101
102
103
104
105
106
107
108
name: CI Workflow Java Maven Branches
on:
push:
branches:
- '*'
- '!master'
jobs:
# see https://docs.github.com/en/actions/language-and-framework-guides/building-and-testing-java-with-maven
build:
name: Create Maven Package
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 8
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and test with Maven
run: mvn -B clean test package
- name: Keep JAR file
uses: actions/upload-artifact@v2
with:
name: Package
path: target/ticketmagpie.jar
# see https://www.prestonlamb.com/blog/creating-a-docker-image-with-github-actions
package:
name: Create Docker image
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Download JAR file
uses: actions/download-artifact@v2
with:
name: Package
path: target
- name: Build the latest Docker image
run: docker build . --file Dockerfile --tag codecop/ticketmagpie:latest
- name: Save Docker image
run: docker save -o docker_image.tar codecop/ticketmagpie:latest
- name: Keep Docker file
uses: actions/upload-artifact@v2
with:
name: Docker
path: docker_image.tar
test:
name: Test against Docker image
runs-on: ubuntu-latest
needs: package
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Download Docker file
uses: actions/download-artifact@v2
with:
name: Docker
path: .
- name: Load Docker image
run: docker load -i docker_image.tar
- name: Start the Docker image
run: docker run -d -e "SPRING_PROFILES_ACTIVE=hsqldb" -e "MAIL_SMTP_HOST=127.0.0.1" -e "MAIL_SMTP_PORT=11112" --net="host" -p8080:8080 codecop/ticketmagpie:latest
# https://stackoverflow.com/questions/31324981/how-to-access-host-port-from-docker-container
# https://stackoverflow.com/a/48806927/104143
- name: Wait for application to start
run: sleep 3
- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 8
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Run system tests
run: mvn -B test-compile failsafe:integration-test failsafe:verify -Dmagpie.server=127.0.0.1 -Dmagpie.port=8080