diff --git a/.github/workflows/cfdeploy.yml b/.github/workflows/cfdeploy.yml index 4160c033..29638653 100644 --- a/.github/workflows/cfdeploy.yml +++ b/.github/workflows/cfdeploy.yml @@ -1,18 +1,13 @@ -name: Deploy and Integration Test +name: Deploy on: - pull_request: - types: [closed] - branches: - - develop workflow_dispatch: permissions: pull-requests: read jobs: - deploy: - if: github.event.pull_request.merged == true + Deploy: runs-on: cap-java steps: @@ -62,101 +57,3 @@ jobs: # Deploy the application echo "Running cf deploy" cf deploy mta_archives/demoappjava_1.0.0.mtar -f - - integration-test: - needs: deploy - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Java 17 - uses: actions/setup-java@v3 - with: - java-version: 17 - distribution: 'temurin' - - - name: Install Cloud Foundry CLI and jq - run: | - wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - - echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list - sudo apt-get update - sudo apt-get install cf8-cli jq - - name: Login to Cloud Foundry - run: | - cf login -a ${{ secrets.CF_API }} \ - -u ${{ secrets.CF_USER }} \ - -p ${{ secrets.CF_PASSWORD }} \ - -o ${{ secrets.CF_ORG }} \ - -s ${{ secrets.CF_SPACE }} - - name: Fetch and Escape Client Secret - id: fetch_secret - run: | - # Fetch the service instance GUID - service_instance_guid=$(cf service demoappjava-public-uaa --guid) - if [ -z "$service_instance_guid" ]; then - echo "Error: Unable to retrieve service instance GUID"; exit 1; - fi - # Fetch the binding GUID - bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}") - - binding_guid=$(echo $bindings_response | jq -r '.resources[0].guid') - if [ -z "$binding_guid" ]; then - echo "Error: Unable to retrieve binding GUID"; exit 1; - fi - - # Fetch the clientSecret - binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details") - clientSecret=$(echo "$binding_details" | jq -r '.credentials.clientsecret') - if [ -z "$clientSecret" ] || [ "$clientSecret" == "null" ]; then - echo "Error: clientSecret is not set or is null"; exit 1; - fi - - # Escape any $ characters in the clientSecret - escapedClientSecret=$(echo "$clientSecret" | sed 's/\$/\\$/g') - echo "::set-output name=CLIENT_SECRET::$escapedClientSecret" - - name: Run integration tests - env: - CLIENT_SECRET: ${{ steps.fetch_secret.outputs.CLIENT_SECRET }} - run: | - set -e # Enable error checking - PROPERTIES_FILE="sdm/src/test/resources/credentials.properties" - # Gather secrets and other values - appUrl="${{ secrets.CF_ORG }}-${{ secrets.CF_SPACE }}-demoappjava-srv.cfapps.eu12.hana.ondemand.com" - authUrl="${{ secrets.CAPAUTH_URL }}" - clientID="${{ secrets.CAPSDM_CLIENT_ID }}" - clientSecret="${{ env.CLIENT_SECRET }}" - username="${{ secrets.CF_USER }}" - password="${{ secrets.CF_PASSWORD }}" - # Ensure all required variables are set - if [ -z "$appUrl" ]; then echo "Error: appUrl is not set"; exit 1; fi - if [ -z "$authUrl" ]; then echo "Error: authUrl is not set"; exit 1; fi - if [ -z "$clientID" ]; then echo "Error: clientID is not set"; exit 1; fi - if [ -z "$clientSecret" ]; then echo "Error: clientSecret is not set"; exit 1; fi - if [ -z "$username" ]; then echo "Error: username is not set"; exit 1; fi - if [ -z "$password" ]; then echo "Error: password is not set"; exit 1; fi - # Function to partially mask sensitive information for logging - mask() { - local value="$1" - if [ ${#value} -gt 6 ]; then - echo "${value:0:3}*****${value: -3}" - else - echo "${value:0:2}*****" - fi - } - # Update properties file with real values - cat > "$PROPERTIES_FILE" < "$PROPERTIES_FILE" < "$PROPERTIES_FILE" <