-
Notifications
You must be signed in to change notification settings - Fork 9
124 lines (103 loc) · 4.47 KB
/
multiTenancyDeployLocal.yml
File metadata and controls
124 lines (103 loc) · 4.47 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Multi Tenancy Deployment Local
on:
workflow_dispatch:
inputs:
cf_space:
description: 'Specify the Cloud Foundry space to deploy to'
required: true
default: 'developcap'
deploy_branch:
description: 'Specify the branch to deploy'
required: false
cds_services_version:
description: 'Optional override for <cds.services.version> (e.g. 4.3.1). Leave blank to use existing value.'
required: false
default: ''
permissions:
pull-requests: read
packages: read # Added permission to read packages
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository 📁
uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.deploy_branch }}
- name: Set up JDK 21 ☕
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
- name: Build and package 📦
run: |
echo "🔨 Building and packaging..."
mvn clean install -P unit-tests -DskipIntegrationTests
echo "✅ Build completed successfully!"
- name: Setup Node.js 🟢
uses: actions/setup-node@v3
with:
node-version: '18' # Ensure to use at least version 18
- name: Install MBT ⚙️
run: |
echo "🔧 Installing MBT..."
npm install -g mbt
echo "✅ MBT installation complete!"
- name: Clone the cloud-cap-samples-java repo 🌐
run: |
echo "🔄 Cloning repository..."
git clone --depth 1 --branch appChngsForCrctPageTitles https://github.com/vibhutikumar07/cloud-cap-samples-java.git
echo "✅ Repository cloned!"
- name: Override cds.services.version (runtime only)
if: ${{ github.event.inputs.cds_services_version != '' }}
env:
TARGET_CDS_SERVICES_VERSION: ${{ github.event.inputs.cds_services_version }}
run: |
echo "Override requested: cds.services.version -> ${TARGET_CDS_SERVICES_VERSION}"
FILES=$(grep -Rl "<cds.services.version>" . | grep pom.xml || true)
if [ -z "$FILES" ]; then
echo "No pom.xml files with <cds.services.version> found" >&2; exit 1;
fi
echo "Updating files:"; echo "$FILES" | sed 's/^/ - /'
for f in $FILES; do
sed -i "s|<cds.services.version>[^<]*</cds.services.version>|<cds.services.version>${TARGET_CDS_SERVICES_VERSION}</cds.services.version>|" "$f"
done
echo "Post-update values:"; grep -R "<cds.services.version>" $FILES || true
echo "(Not committing these changes)"
shell: bash
- name: Change directory to cloud-cap-samples-java 📂
working-directory: cloud-cap-samples-java
run: |
pwd
echo "✔️ Directory changed!"
- name: Run mbt build 🔨
working-directory: cloud-cap-samples-java
run: |
echo "🚀 Running MBT build..."
echo "java version:"
java --version
mbt build
echo "✅ MBT build completed!"
- name: Deploy to Cloud Foundry ☁️
working-directory: cloud-cap-samples-java
run: |
echo "🚀 Deploying to -s ${{ steps.determine_space.outputs.space }}..."
echo "🔧 Installing Cloud Foundry CLI and plugins..."
# Install cf CLI plugin
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo tee /etc/apt/trusted.gpg.d/cloudfoundry.asc
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt update
sudo apt install cf-cli
cf install-plugin multiapps -f
echo "✅ Cloud Foundry CLI setup complete!"
# Login to Cloud Foundry again to ensure session is active
echo "🔑 Logging in to Cloud Foundry..."
cf login -a ${{ secrets.CF_API }} -u ${{ secrets.CF_USER }} -p ${{ secrets.CF_PASSWORD }} -o ${{ secrets.CF_ORG }} -s ${{ github.event.inputs.cf_space }}
echo "✅ Logged in successfully!"
# Deploy the application
echo "📂 Current directory.."
pwd
ls -lrth
echo "▶️ Running cf deploy..."
cf deploy mta_archives/bookshop-mt_1.0.0.mtar -f
echo "✅ Deployment complete!"