Multi Tenancy Deployment Local #122
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 local_mtTests 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!" |