-
Notifications
You must be signed in to change notification settings - Fork 14
101 lines (96 loc) · 2.93 KB
/
maven-deploy.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
name: Maven Deploy
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
shell: bash
- name: Build project
run: |
mvn versions:set -DnewVersion=${{ steps.get_version.outputs.VERSION }}
mvn versions:commit
mvn clean
mvn install -P prod
- name: Archive server
uses: actions/upload-artifact@v4
with:
name: Server
path: backend/target/server.jar
deploy-github:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- name: Get release
id: get_release
uses: bruceadams/get-release@v1.2.3
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: Server
path: backend/target/
- name: Archive application wait html
run: tar -C script/ -cf wait-for-app.tar wait-for-app-html
- name: Github release
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: true
files: |
backend/target/server.jar
wait-for-app.tar
deploy-docker:
runs-on: ubuntu-latest
needs: [build]
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: alex9849
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
shell: bash
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: Server
path: backend/target/
- name: Build images
run: |
docker build -t alex9849/cocktailpi:${{ steps.get_version.outputs.VERSION }} -f script/docker/Dockerfile .
docker tag alex9849/cocktailpi:${{ steps.get_version.outputs.VERSION }} alex9849/cocktailpi:latest
- name: Push images
run: docker push alex9849/cocktailpi --all-tags