Skip to content

Commit c39bfef

Browse files
committed
Initial commit
1 parent cb9d09d commit c39bfef

File tree

2 files changed

+132
-10
lines changed

2 files changed

+132
-10
lines changed

.github/workflows/deploy.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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' }}

tests/non-draft-request.http

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
### Get list of all incidents
77
# @name incidents
8-
GET {{host}}/odata/v4/processor/Incidents
8+
GET {{host}}/odata/v4/admin/Incidents
99
Authorization: {{auth}}
1010

1111
### Creating attachment (metadata request)
1212
@incidentsID = {{incidents.response.body.value[2].ID}}
1313
# @name createAttachment
14-
POST {{host}}/odata/v4/processor/Incidents({{incidentsID}})/attachments
14+
POST {{host}}/odata/v4/admin/Incidents({{incidentsID}})/attachments
1515
Authorization: {{auth}}
1616
Content-Type: application/json
1717

@@ -21,40 +21,40 @@ Content-Type: application/json
2121

2222
### Put attachment content (content request)
2323
@attachmentsID = {{createAttachment.response.body.ID}}
24-
PUT {{host}}/odata/v4/processor/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})/content
24+
PUT {{host}}/odata/v4/admin/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})/content
2525
Authorization: {{auth}}
2626
Content-Type: image/jpeg
2727

2828
< ./integration/content/sample-1.jpg
2929

3030
### Get newly created attachment metadata
31-
GET {{host}}/odata/v4/processor/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})
31+
GET {{host}}/odata/v4/admin/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})
3232
Authorization: {{auth}}
3333

3434
### Fetching newly created attachment content
35-
GET {{host}}/odata/v4/processor/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})/content
35+
GET {{host}}/odata/v4/admin/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})/content
3636
Authorization: {{auth}}
3737

3838
### Get list of attachments for a particular incident
3939
# @name attachments
40-
GET {{host}}/odata/v4/processor/Incidents(ID={{incidentsID}})/attachments
40+
GET {{host}}/odata/v4/admin/Incidents(ID={{incidentsID}})/attachments
4141
Authorization: {{auth}}
4242

4343
### Get attachments content
44-
GET {{host}}/odata/v4/processor/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})/content
44+
GET {{host}}/odata/v4/admin/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})/content
4545
Authorization: {{auth}}
4646

4747
### Get attachments content with up__ID included
48-
GET {{host}}/odata/v4/processor/Incidents({{incidentsID}})/attachments(up__ID={{incidentsID}},ID={{attachmentsID}})/content
48+
GET {{host}}/odata/v4/admin/Incidents({{incidentsID}})/attachments(up__ID={{incidentsID}},ID={{attachmentsID}})/content
4949
Authorization: {{auth}}
5050

5151
### Put attachment content (content request) with up__ID included
52-
PUT {{host}}/odata/v4/processor/Incidents({{incidentsID}})/attachments(up__ID={{incidentsID}},ID={{attachmentsID}})/content
52+
PUT {{host}}/odata/v4/admin/Incidents({{incidentsID}})/attachments(up__ID={{incidentsID}},ID={{attachmentsID}})/content
5353
Authorization: {{auth}}
5454
Content-Type: image/jpeg
5555

5656
< ./integration/content/sample-1.jpg
5757

5858
### Delete attachment
59-
DELETE {{host}}/odata/v4/processor/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})
59+
DELETE {{host}}/odata/v4/admin/Incidents({{incidentsID}})/attachments(ID={{attachmentsID}})
6060
Authorization: {{auth}}

0 commit comments

Comments
 (0)