|
| 1 | +name: "Deploy to Cloud Foundry" |
| 2 | +description: "Logs into Cloud Foundry and deploys the application" |
| 3 | +inputs: |
| 4 | + CF_API: |
| 5 | + description: "Cloud Foundry API endpoint" |
| 6 | + required: true |
| 7 | + CF_USERNAME: |
| 8 | + description: "Cloud Foundry username" |
| 9 | + required: true |
| 10 | + CF_PASSWORD: |
| 11 | + description: "Cloud Foundry password" |
| 12 | + required: true |
| 13 | + CF_ORG: |
| 14 | + description: "Cloud Foundry organization" |
| 15 | + required: true |
| 16 | + CF_SPACE: |
| 17 | + description: "Cloud Foundry space" |
| 18 | + required: true |
| 19 | + CF_APP_NAME: |
| 20 | + description: "Cloud Foundry application name" |
| 21 | + required: true |
| 22 | +runs: |
| 23 | + using: "composite" |
| 24 | + steps: |
| 25 | + - name: Install dependencies and Cloud Foundry CLI (v8.9.0) |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + sudo apt-get update |
| 29 | + sudo apt-get install -y libc6 wget tar |
| 30 | + wget "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=8.9.0&source=github-rel" -O cf-cli.tar.gz |
| 31 | + tar -xvzf cf-cli.tar.gz |
| 32 | + sudo mv cf /usr/local/bin/ |
| 33 | + sudo mv cf8 /usr/local/bin/ |
| 34 | + cf --version |
| 35 | +
|
| 36 | + - name: Authenticate with Cloud Foundry |
| 37 | + shell: bash |
| 38 | + run: | |
| 39 | + echo "::debug::CF_API=${{ inputs.CF_API }}" |
| 40 | + for i in {1..3}; do |
| 41 | + cf login -a ${{ inputs.CF_API }} -u ${{ inputs.CF_USERNAME }} -p ${{ inputs.CF_PASSWORD }} -o ${{ inputs.CF_ORG }} -s ${{ inputs.CF_SPACE }} && break |
| 42 | + echo "cf login failed, retrying ($i/3)..." |
| 43 | + sleep 10 |
| 44 | + if [ "$i" -eq 3 ]; then |
| 45 | + echo "❌ cf login failed after 3 attempts." |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | + done |
| 49 | +
|
| 50 | + - name: Install Multi-Target Application Build Tool (MBT) |
| 51 | + shell: bash |
| 52 | + run: npm install -g mbt |
| 53 | + |
| 54 | + - name: Check if mta.yaml Exists |
| 55 | + shell: bash |
| 56 | + working-directory: incidents-app |
| 57 | + run: | |
| 58 | + test -f mta.yaml && echo "✅ mta.yaml found!" || echo "⚠️ WARNING: mta.yaml NOT found!" |
| 59 | + |
| 60 | + - name: Build MTA archive |
| 61 | + shell: bash |
| 62 | + working-directory: incidents-app |
| 63 | + run: mbt build -t gen --mtar mta.tar |
| 64 | + |
| 65 | + - name: Install Cloud Foundry MultiApps Plugin |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + cf install-plugin -f https://github.com/cloudfoundry-incubator/multiapps-cli-plugin/releases/latest/download/multiapps-plugin.linux64 |
| 69 | + cf plugins |
| 70 | +
|
| 71 | + - name: Undeploy existing apps if exists |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + for APP in incidents-testing incidents-testingMTX; do |
| 75 | + echo "🔍 Attempting to undeploy $APP" |
| 76 | + echo "y" | cf undeploy "$APP" --delete-services --delete-service-keys || echo "⚠️ $APP not found or undeploy failed" |
| 77 | + done |
| 78 | +
|
| 79 | + - name: Deploy to Cloud Foundry |
| 80 | + shell: bash |
| 81 | + working-directory: incidents-app |
| 82 | + run: cf deploy gen/mta.tar -f |
0 commit comments