-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathci-workflow-java-maven-docker.yml
More file actions
51 lines (42 loc) · 1.34 KB
/
Copy pathci-workflow-java-maven-docker.yml
File metadata and controls
51 lines (42 loc) · 1.34 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
name: CI Workflow Java Maven Docker
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Maven packages
uses: actions/cache@v4
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@v4
with:
name: Package
path: target/push-counter-1.0-SNAPSHOT-jar-with-dependencies.jar
package:
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Download JAR file
uses: actions/download-artifact@v4
with:
name: Package
path: target
- name: Build the latest Docker image
run: docker build . --file Dockerfile --tag codecop/push-counter:latest
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Push the latest Docker image to Docker Hub
run: docker push codecop/push-counter:latest