2020 check_changes :
2121 runs-on : ubuntu-latest
2222 outputs :
23- postgresql_changed : ${{ steps.filter.outputs.postgresql_changed || 'false' }}
24- uptime_kuma_2_changed : ${{ steps.filter.outputs.uptime_kuma_2_changed || 'false' }}
25- base_changed : ${{ steps.filter.outputs.base_changed || 'false' }}
23+ apps_json : ${{ steps.emit.outputs.apps_json }}
2624 steps :
2725 - if : ${{ github.event_name == 'push' }}
2826 uses : actions/checkout@v4
@@ -44,17 +42,41 @@ jobs:
4442 - 'base/**'
4543 - 'scripts/base/ampstart.sh'
4644
45+ - id : emit
46+ shell : bash
47+ run : |
48+ set -euo pipefail
49+ # Default matrix when not a push: build all apps
50+ if [ "${{ github.event_name }}" != "push" ]; then
51+ echo 'apps_json=["postgresql","uptime-kuma-2"]' >> "$GITHUB_OUTPUT"
52+ exit 0
53+ fi
54+
55+ # On push: if base changed, build nothing (let base workflow handle rebuilds)
56+ if [ "${{ steps.filter.outputs.base_changed || 'false' }}" = "true" ]; then
57+ echo 'apps_json=[]' >> "$GITHUB_OUTPUT"
58+ exit 0
59+ fi
60+
61+ apps=()
62+ if [ "${{ steps.filter.outputs.postgresql_changed || 'false' }}" = "true" ]; then apps+=('"postgresql"'); fi
63+ if [ "${{ steps.filter.outputs.uptime_kuma_2_changed || 'false' }}" = "true" ]; then apps+=('"uptime-kuma-2"'); fi
64+
65+ if [ "${#apps[@]}" -eq 0 ]; then
66+ echo 'apps_json=[]' >> "$GITHUB_OUTPUT"
67+ else
68+ printf 'apps_json=[%s]\n' "$(IFS=,; echo "${apps[*]}")" >> "$GITHUB_OUTPUT"
69+ fi
70+
4771 build_and_push :
4872 needs : [check_changes]
49- if : ${{ github.repository_owner == 'CubeCoders' && github.ref == 'refs/heads/master' && (( github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || (github.event_name == 'workflow_dispatch') || (github.event_name == 'push' && needs.check_changes.outputs.base_changed != 'true' && ((matrix.app == 'postgresql' && needs.check_changes.outputs.postgresql_changed == 'true') || (matrix.app == 'uptime-kuma-2' && needs.check_changes.outputs.uptime_kuma_2_changed == 'true'))) }}
73+ if : ${{ github.repository_owner == 'CubeCoders' && github.ref == 'refs/heads/master' && (github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success') }}
5074 name : ' amp:apps-${{ matrix.app }}'
5175 runs-on : ubuntu-latest
5276 strategy :
5377 fail-fast : false
5478 matrix :
55- app :
56- - postgresql
57- - uptime-kuma-2
79+ app : ${{ fromJSON(needs.check_changes.outputs.apps_json) }}
5880
5981 steps :
6082 - uses : actions/checkout@v4
0 commit comments