-
Notifications
You must be signed in to change notification settings - Fork 5
98 lines (80 loc) · 2.82 KB
/
ci.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
# © 2024. TU Dortmund University,
# Institute of Energy Systems, Energy Efficiency and Energy Economics,
# Research group Distribution grid planning and operation
#
name: CI
on:
push:
paths-ignore:
- 'docs/**'
branches:
- main
- dev
- 'hotfix/*'
- 'rel/*'
- 'dependabot/*'
pull_request:
branches:
- main
- dev
jobs:
buildAndTest:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Check Branch
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
branchName="${{ github.head_ref }}"
else
branchName="${{ github.ref_name }}"
fi
if [[ "$branchName" == refs/heads/* ]]; then
branchName="${branchName#refs/heads/}"
fi
./gradlew checkBranchName -PbranchName="$branchName"
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Build Project
run: ./gradlew --refresh-dependencies clean assemble spotlessCheck
- name: Run Tests
run: ./gradlew test reportScoverage checkScoverage
- name: Build Scala-Docs
run: ./gradlew scaladoc
- name: SonarQube
run: |
./gradlew sonar \
-Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \
-Dsonar.host.url=${{ vars.SONAR_HOST_URL }} \
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
SONAR_STATUS_URL="${{ vars.SONAR_HOST_URL }}/api/qualitygates/project_status?projectKey=${{ vars.SONAR_PROJECT_KEY }}"
QUALITY_GATE_STATUS=$(curl -s -u "${{ secrets.SONAR_TOKEN }}:" "$SONAR_STATUS_URL" | jq -r '.projectStatus.status')
echo "Quality Gate Status: $QUALITY_GATE_STATUS"
if [ "$QUALITY_GATE_STATUS" != "OK" ]; then
echo "Quality Gate failed!"
exit 1
fi
#Deployment
- name: Deploy
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVENCENTRAL_SIGNINGKEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVENCENTRAL_SIGNINGPASS }}
ORG_GRADLE_PROJECT_user: ${{ secrets.MAVENCENTRAL_USER }}
ORG_GRADLE_PROJECT_password: ${{ secrets.MAVENCENTRAL_PASS }}
run: |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
currentVersion=$(./gradlew -q currentVersion)
else
currentVersion=$(./gradlew -q devVersion)
fi
echo "currentVersion=$currentVersion"
./gradlew publish -PdeployVersion=$currentVersion