1+ name : Deploy Incidents App
2+
3+ on :
4+ push :
5+ branches : [main]
6+ workflow_dispatch :
7+ pull_request_target :
8+ branches : [ main ]
9+ types : [ reopened, synchronize, opened ]
10+
11+ jobs :
12+ requires-approval :
13+ runs-on : ubuntu-latest
14+ name : " Waiting for PR approval as this workflow runs on pull_request_target"
15+ if : github.event_name == 'pull_request_target' && github.event.pull_request.base.user.login != 'cap-js'
16+ environment : pr-approval
17+ steps :
18+ - name : Approval Step
19+ run : echo "This job has been approved!"
20+ deploy :
21+ name : Deploy ${{ matrix.tenant }} App
22+ runs-on : ubuntu-latest
23+ needs : requires-approval
24+ if : always() && (needs.requires-approval.result == 'success' || needs.requires-approval.result == 'skipped')
25+ strategy :
26+ matrix :
27+ tenant : [singletenant, multitenant]
28+ permissions :
29+ contents : read
30+ issues : write
31+ pull-requests : write
32+ steps :
33+ - name : Checkout repository
34+ uses : actions/checkout@v4
35+
36+ - name : Clone Incidents App Repository
37+ run : |
38+ if [[ "${{ matrix.tenant }}" == "singletenant" ]]; then
39+ git clone --branch attachmentsE2E --single-branch https://github.com/cap-js/incidents-app.git
40+ else
41+ git clone --branch attachmentsE2EMTX --single-branch https://github.com/cap-js/incidents-app.git
42+ fi
43+
44+ - name : Install dependencies
45+ working-directory : incidents-app
46+ run : npm install
47+ - name : Use PR branch version of @cap-js/attachments
48+ if : github.event_name == 'pull_request'
49+ working-directory : incidents-app
50+ run : |
51+ BRANCH_NAME=${{ github.head_ref }}
52+ echo "🔄 Using @cap-js/attachments branch: $BRANCH_NAME"
53+
54+ # Override in app-level package.json
55+ jq --arg url "git+https://github.com/cap-js/attachments.git#$BRANCH_NAME" \
56+ '.dependencies["@cap-js/attachments"] = $url' package.json > tmp.json && mv tmp.json package.json
57+
58+ # Also override in mtx/sidecar if multitenant
59+ if [[ "${{ matrix.tenant }}" == "multitenant" ]]; then
60+ jq --arg url "git+https://github.com/cap-js/attachments.git#$BRANCH_NAME" \
61+ '.dependencies["@cap-js/attachments"] = $url' mtx/sidecar/package.json > tmp.json && mv tmp.json mtx/sidecar/package.json
62+ fi
63+
64+ # Install updated dependencies
65+ npm install
66+ if [[ "${{ matrix.tenant }}" == "multitenant" ]]; then
67+ npm install --prefix mtx/sidecar
68+ fi
69+
70+ - name : Set up Node.js
71+ uses : actions/setup-node@v4
72+ with :
73+ node-version : " 22"
74+
75+ - name : Install CDS CLI
76+ run : npm install -g @sap/cds
77+
78+ - name : Configure application features
79+ working-directory : incidents-app
80+ run : |
81+ if [[ "${{ matrix.tenant }}" == "singletenant" ]]; then
82+ npx cds add hana,xsuaa,workzone --for production
83+ else
84+ npx cds add hana,xsuaa,multitenancy --for production
85+ fi
86+
87+ - name : Fix xs-app.json destination (singletenant only)
88+ if : matrix.tenant == 'singletenant'
89+ working-directory : incidents-app/app/incidents
90+ run : |
91+ jq '(.routes[] | select(.destination == "srv-api")).destination = "incidents-testing-srv-api"' xs-app.json > tmp.json && mv tmp.json xs-app.json
92+
93+ - name : Install additional dependencies
94+ working-directory : incidents-app
95+ run : |
96+ npm install
97+ npm install --prefix app/incidents
98+ if [[ "${{ matrix.tenant }}" == "multitenant" ]]; then
99+ npm install --prefix mtx/sidecar
100+ npm install @sap/xsenv --prefix mtx/sidecar
101+ fi
102+
103+ - name : Freeze npm dependencies (multitenant only)
104+ if : matrix.tenant == 'multitenant'
105+ working-directory : incidents-app
106+ run : |
107+ npm update --package-lock-only
108+ npm update --package-lock-only --prefix mtx/sidecar
109+
110+ - name : Build application
111+ working-directory : incidents-app
112+ run : npx cds build --production
113+
114+ - name : Deploy to SAP BTP Cloud Foundry
115+ uses : ./.github/actions/deploy
116+ with :
117+ CF_API : ${{ secrets.CF_API_AWS }}
118+ CF_USERNAME : ${{ secrets.CF_USERNAME }}
119+ CF_PASSWORD : ${{ secrets.CF_PASSWORD }}
120+ CF_ORG : ${{ secrets.CF_ORG_AWS }}
121+ CF_SPACE : ${{ secrets.CF_SPACE_AWS }}
122+ CF_APP_NAME : ${{ matrix.tenant == 'singletenant' && 'incidents-testing' || 'incidents-testing-mtx' }}
0 commit comments