-
Notifications
You must be signed in to change notification settings - Fork 3
80 lines (73 loc) · 2.53 KB
/
buildandeploy.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
name: Build & Deploy
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Github Packages Docker Registry
if: startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get the version
id: get_version
run: |
REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
VERSION=$(echo $GITHUB_REF | grep -o '[^/]*$')
FULL_VERSION=$(echo $GITHUB_REF | cut -d / -f 3-)
RELEASE=false
echo ::set-output name=REPO::$REPO
echo ::set-output name=VERSION::$VERSION
if [[ $FULL_VERSION =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]]; then
TAG="latest"
RELEASE=true
elif [[ $FULL_VERSION =~ ^b[0-9]+.[0-9]+.[0-9]+$ ]]; then
TAG="latest-beta"
RELEASE=true
else
TAG="latest-dev"
fi
echo ::set-output name=TAG::$TAG
echo ::set-output name=RELEASE::$RELEASE
echo "Full Version: $FULL_VERSION | Version: $VERSION | Tag: $TAG | Release?: $RELEASE"
- name: Build and push
uses: docker/build-push-action@v4
with:
push: ${{ steps.get_version.outputs.RELEASE }}
cache-from: type=gha
cache-to: type=gha
tags: |
ghcr.io/${{ steps.get_version.outputs.REPO }}:${{ steps.get_version.outputs.VERSION }}
ghcr.io/${{ steps.get_version.outputs.REPO }}:${{ steps.get_version.outputs.TAG }}
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "19"
- name: Build project
uses: gradle/gradle-build-action@v2
with:
arguments: test jacocoTestReport
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: Upload test report
uses: actions/upload-artifact@v3
with:
path: build/reports/tests/test/
name: Test Report
retention-days: 14
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
path: build/reports/jacoco/test/
name: Coverage Report
retention-days: 14