-
Notifications
You must be signed in to change notification settings - Fork 4
113 lines (101 loc) · 4.26 KB
/
build.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
101
102
103
104
105
106
107
108
109
110
111
112
113
# This workflow builds the project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: build
on:
push:
branches:
- '**'
tags:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code base
# https://github.com/actions/checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 11
# https://github.com/actions/setup-java
uses: actions/setup-java@v2
with:
cache: 'maven'
check-latest: true
distribution: 'adopt'
java-version: 11
- name: Prepare Sonar cache
# https://github.com/actions/cache
uses: actions/cache@v2.1.7
with:
path: ~/.sonar/cache
key: sonar
- name: Prepare Maven settings
# https://github.com/s4u/maven-settings-action
uses: s4u/maven-settings-action@v2.5.0
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
with:
servers: '[{"id": "ossrh", "username": "${{ secrets.OSSRH_USERNAME }}", "password": "${{ secrets.OSSRH_PASSWORD }}"}]'
- name: Prepare GPG environment
# https://github.com/crazy-max/ghaction-import-gpg
uses: crazy-max/ghaction-import-gpg@v3.1.0
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
with:
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Verify artifacts
if: github.ref == 'refs/heads/main' != true && startsWith(github.ref, 'refs/tags/') != true
run: mvn -B verify
- name: Deploy artifacts
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: mvn -B -Possrh deploy
- name: Upload coverage report to SonarCloud
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
- name: Prepare main documentation
id: prepare-main-documentation
if: github.ref == 'refs/heads/main'
run: |
TAG_NAME="current"
echo "::set-output name=dest_dir::${TAG_NAME}"
- name: Publish main documentation
# https://github.com/peaceiris/actions-gh-pages
uses: peaceiris/actions-gh-pages@v3.8.0
if: github.ref == 'refs/heads/main'
with:
cname: spring-hateoas-siren.ingogriebsch.de
commit_message: 'docs: publish main documentation to gh-pages'
destination_dir: ${{ steps.prepare-main-documentation.outputs.dest_dir }}
github_token: ${{ secrets.GITHUB_TOKEN }}
keep_files: true
publish_branch: gh-pages
publish_dir: ./target/generated-docs
user_email: 'github-actions[bot]@users.noreply.github.com'
user_name: 'github-actions[bot]'
- name: Prepare tags documentation
id: prepare-tags-documentation
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG_NAME="${GITHUB_REF##refs/tags/}"
echo "::set-output name=dest_dir::${TAG_NAME}"
echo "::set-output name=base_tag::${TAG_NAME}"
echo "::set-output name=tag_name::${TAG_NAME}-docs"
- name: Publish tags documentation
# https://github.com/peaceiris/actions-gh-pages
uses: peaceiris/actions-gh-pages@v3.8.0
if: startsWith(github.ref, 'refs/tags/')
with:
cname: spring-hateoas-siren.ingogriebsch.de
commit_message: 'docs: publish tags documentation to gh-pages'
destination_dir: ${{ steps.prepare-tags-documentation.outputs.dest_dir }}
github_token: ${{ secrets.GITHUB_TOKEN }}
keep_files: true
publish_branch: gh-pages
publish_dir: ./target/generated-docs
tag_message: 'Tag documentation for ${{ steps.prepare-tags-documentation.outputs.base_tag }}'
tag_name: ${{ steps.prepare-tags-documentation.outputs.tag_name }}
user_email: 'github-actions[bot]@users.noreply.github.com'
user_name: 'github-actions[bot]'