Skip to content

Commit 63478fb

Browse files
ci: selective module build - only build changed modules
1 parent 185335e commit 63478fb

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/manual.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,66 @@ on:
44
workflow_dispatch: # Ermöglicht manuelle Ausführung des Workflows
55

66
jobs:
7+
detect-changes:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
app_changed: ${{ steps.changes.outputs.app }}
11+
humanoperator_changed: ${{ steps.changes.outputs.humanoperator }}
12+
shared_changed: ${{ steps.changes.outputs.shared }}
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 2 # Letzten 2 Commits holen für Diff
18+
19+
- name: Detect changed files
20+
id: changes
21+
run: |
22+
# Geänderte Dateien im letzten Commit ermitteln
23+
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || echo "")
24+
25+
# Falls kein vorheriger Commit existiert (erster Commit), alles bauen
26+
if [ -z "$CHANGED_FILES" ]; then
27+
echo "app=true" >> $GITHUB_OUTPUT
28+
echo "humanoperator=true" >> $GITHUB_OUTPUT
29+
echo "shared=true" >> $GITHUB_OUTPUT
30+
echo "No previous commit found - building all modules"
31+
exit 0
32+
fi
33+
34+
echo "Changed files:"
35+
echo "$CHANGED_FILES"
36+
37+
# Prüfen ob shared/root files geändert wurden (build.gradle, settings.gradle, etc.)
38+
SHARED_CHANGED=false
39+
if echo "$CHANGED_FILES" | grep -qE '^(build\.gradle|settings\.gradle|gradle\.properties|gradle/|buildSrc/)'; then
40+
SHARED_CHANGED=true
41+
fi
42+
43+
# Prüfen ob app/ Dateien geändert wurden
44+
APP_CHANGED=false
45+
if echo "$CHANGED_FILES" | grep -q '^app/'; then
46+
APP_CHANGED=true
47+
fi
48+
49+
# Prüfen ob humanoperator/ Dateien geändert wurden
50+
HUMANOPERATOR_CHANGED=false
51+
if echo "$CHANGED_FILES" | grep -q '^humanoperator/'; then
52+
HUMANOPERATOR_CHANGED=true
53+
fi
54+
55+
echo "app=$APP_CHANGED" >> $GITHUB_OUTPUT
56+
echo "humanoperator=$HUMANOPERATOR_CHANGED" >> $GITHUB_OUTPUT
57+
echo "shared=$SHARED_CHANGED" >> $GITHUB_OUTPUT
58+
59+
echo "Results: app=$APP_CHANGED, humanoperator=$HUMANOPERATOR_CHANGED, shared=$SHARED_CHANGED"
60+
761
build:
62+
needs: detect-changes
863
runs-on: ubuntu-latest
64+
env:
65+
BUILD_APP: ${{ needs.detect-changes.outputs.app_changed == 'true' || needs.detect-changes.outputs.shared_changed == 'true' }}
66+
BUILD_HUMANOPERATOR: ${{ needs.detect-changes.outputs.humanoperator_changed == 'true' || needs.detect-changes.outputs.shared_changed == 'true' }}
967

1068
steps:
1169
- name: Checkout code
@@ -38,19 +96,31 @@ jobs:
3896
run: chmod +x gradlew
3997

4098
- name: Build app module (debug)
99+
if: env.BUILD_APP == 'true'
41100
run: ./gradlew :app:assembleDebug
42101

43102
- name: Build humanoperator module (debug)
103+
if: env.BUILD_HUMANOPERATOR == 'true'
44104
run: ./gradlew :humanoperator:assembleDebug
45105

46106
- name: Upload app APK
107+
if: env.BUILD_APP == 'true'
47108
uses: actions/upload-artifact@v4
48109
with:
49110
name: app-debug
50111
path: app/build/outputs/apk/debug/app-debug.apk
51112

52113
- name: Upload humanoperator APK
114+
if: env.BUILD_HUMANOPERATOR == 'true'
53115
uses: actions/upload-artifact@v4
54116
with:
55117
name: humanoperator-debug
56118
path: humanoperator/build/outputs/apk/debug/humanoperator-debug.apk
119+
120+
- name: Build summary
121+
run: |
122+
echo "### Build Summary" >> $GITHUB_STEP_SUMMARY
123+
echo "| Module | Built |" >> $GITHUB_STEP_SUMMARY
124+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
125+
echo "| app | ${{ env.BUILD_APP }} |" >> $GITHUB_STEP_SUMMARY
126+
echo "| humanoperator | ${{ env.BUILD_HUMANOPERATOR }} |" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)