|
| 1 | +name: Multi Tenancy Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + branches: |
| 7 | + - develop |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + pull-requests: read |
| 12 | + packages: read # Added permission to read packages |
| 13 | + |
| 14 | +jobs: |
| 15 | + deploy: |
| 16 | + if: github.event.pull_request.merged == true |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + |
| 21 | + - name: Wait for 5 minutes # Added a 5-minute delay to ensure the snapshot is deployed successfully before initiating the deployment job. |
| 22 | + run: sleep 300 |
| 23 | + |
| 24 | + - name: Checkout this repository |
| 25 | + uses: actions/checkout@v2 |
| 26 | + |
| 27 | + - name: Set up JDK 21 |
| 28 | + uses: actions/setup-java@v3 |
| 29 | + with: |
| 30 | + distribution: 'temurin' |
| 31 | + java-version: '21' |
| 32 | + |
| 33 | + - name: Build and package |
| 34 | + run: | |
| 35 | + mvn clean install -P unit-tests -DskipIntegrationTests |
| 36 | + |
| 37 | + - name: Setup Node.js |
| 38 | + uses: actions/setup-node@v3 |
| 39 | + with: |
| 40 | + node-version: '18' # Change this to at least version 18 |
| 41 | + |
| 42 | + - name: Install MBT |
| 43 | + run: npm install -g mbt |
| 44 | + |
| 45 | + - name: Clone the cloud-cap-samples-java repo |
| 46 | + run: git clone --depth 1 --branch mtTests https://github.com/vibhutikumar07/cloud-cap-samples-java.git |
| 47 | + |
| 48 | + - name: Change directory to cloud-cap-samples-java |
| 49 | + working-directory: cloud-cap-samples-java |
| 50 | + run: pwd # Verifies that we're in the correct directory |
| 51 | + |
| 52 | + - name: Run mbt build |
| 53 | + working-directory: cloud-cap-samples-java |
| 54 | + run: | |
| 55 | + echo "java version" |
| 56 | + java --version |
| 57 | + mbt build |
| 58 | + |
| 59 | + - name: Deploy to Cloud Foundry |
| 60 | + working-directory: cloud-cap-samples-java |
| 61 | + run: | |
| 62 | + echo "Deploying to ${{ secrets.CF_SPACE }}......" |
| 63 | + |
| 64 | + # Install cf CLI plugin |
| 65 | + |
| 66 | + wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo tee /etc/apt/trusted.gpg.d/cloudfoundry.asc |
| 67 | + echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list |
| 68 | + sudo apt update |
| 69 | + sudo apt install cf-cli |
| 70 | + |
| 71 | + cf install-plugin multiapps -f |
| 72 | + |
| 73 | + # Login to Cloud Foundry again to ensure session is active |
| 74 | + cf login -a ${{ secrets.CF_API }} -u ${{ secrets.CF_USER }} -p ${{ secrets.CF_PASSWORD }} -o ${{ secrets.CF_ORG }} -s ${{ secrets.CF_SPACE }} |
| 75 | + |
| 76 | + # Deploy the application |
| 77 | + echo "Current directory.." |
| 78 | + pwd |
| 79 | + ls -lrth |
| 80 | + echo "Running cf deploy" |
| 81 | + cf deploy mta_archives/bookshop-mt_1.0.0.mtar -f |
0 commit comments